Adjust player and jump pad physics parameters; refine visual effects and project settings
This commit is contained in:
@@ -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))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user