Adjust player and jump pad physics parameters; refine visual effects and project settings

This commit is contained in:
2025-12-13 15:57:15 +01:00
parent 0d0c92fc83
commit 3a56ec7526
10 changed files with 205 additions and 215 deletions

View File

@@ -45,6 +45,7 @@ namespace Infrastructure.Unity
private bool _isGameRunning;
private int _currentPlayerFloorIndex;
private int _currentDisplayedScore;
private float _inputBlockTimer;
private void OnEnable()
{
@@ -61,6 +62,7 @@ namespace Infrastructure.Unity
private void Start()
{
_inputBlockTimer = 0.5f;
_persistenceService = new PlayerPrefsPersistenceAdapter();
_gameSession = new GameSession(_allTiles, _persistenceService);
@@ -98,6 +100,12 @@ namespace Infrastructure.Unity
private void Update()
{
if (_inputBlockTimer > 0f)
{
_inputBlockTimer -= Time.deltaTime;
return;
}
if (!_isGameRunning)
{
if (_actions.Player.StartGame.triggered)

View File

@@ -10,15 +10,7 @@ namespace Infrastructure.Unity
[Self][SerializeField] private MeshRenderer meshRenderer;
public event Action OnCollected;
private MaterialPropertyBlock _propBlock;
private static readonly int ColorProperty = Shader.PropertyToID("_BaseColor");
private void Awake()
{
_propBlock = new MaterialPropertyBlock();
}
private void OnTriggerEnter(Collider other)
{
if (other.TryGetComponent<PlayerController>(out var player))
@@ -28,8 +20,7 @@ namespace Infrastructure.Unity
var vfx = Instantiate(pickupVfx, transform.position, Quaternion.identity);
var main = vfx.main;
meshRenderer.GetPropertyBlock(_propBlock);
var currentColor = _propBlock.GetColor(ColorProperty);
var currentColor = meshRenderer.material.color;
main.startColor = currentColor;
Destroy(vfx.gameObject, 2f);

View File

@@ -43,6 +43,7 @@ namespace Infrastructure.Unity
private bool _isGrounded;
private float _coyoteTimeCounter;
private bool _jumpPressed;
private Vector3 _currentTileCentroid;
public Rigidbody Rigidbody => rb;
public StatusManager Status { get; private set; }
@@ -125,7 +126,15 @@ namespace Infrastructure.Unity
private void CheckGround()
{
_isGrounded = Physics.Raycast(transform.position, Vector3.down, groundCheckDistance, tileLayer);
if (Physics.SphereCast(transform.position, 0.3f, Vector3.down, out var hit, groundCheckDistance, tileLayer))
{
_isGrounded = true;
_currentTileCentroid = hit.collider.transform.position;
}
else
{
_isGrounded = false;
}
}
private void PerformJump()
@@ -213,18 +222,25 @@ namespace Infrastructure.Unity
private void ApplySnapping(Vector3 axis)
{
if (!_isGrounded) return;
var targetPos = Vector3.Dot(_currentTileCentroid, axis);
var currentPos = Vector3.Dot(transform.position, axis);
var targetPos = Mathf.Round(currentPos);
var diff = targetPos - currentPos;
var correction = axis * (diff * snapForce);
rb.AddForce(correction, ForceMode.Acceleration);
var currentVelOnAxis = Vector3.Dot(rb.linearVelocity, axis);
var targetVel = diff * snapForce;
var correction = axis * (targetVel - currentVelOnAxis);
rb.AddForce(correction, ForceMode.VelocityChange);
}
private void InteractWithGround()
{
if (Physics.Raycast(transform.position, Vector3.down, out var hit, groundCheckDistance, tileLayer))
if (Physics.SphereCast(transform.position, 0.3f, Vector3.down, out var hit, groundCheckDistance, tileLayer))
{
if (hit.collider.TryGetComponent<TileViewAdapter>(out var tileAdapter))
{

View File

@@ -169,7 +169,7 @@ namespace Infrastructure.Unity
{
var t = 0f;
var startScale = transform.localScale;
while (t < 1f)
while (t < 0.4f)
{
t += Time.deltaTime;
transform.localScale = Vector3.Lerp(startScale, Vector3.zero, t);