Adjust JumpPad jumpForce and PlayerController movement settings for improved gameplay dynamics

This commit is contained in:
2025-12-12 23:16:48 +01:00
parent ee7a2fb4cb
commit c0fb207768
4 changed files with 44 additions and 12 deletions

View File

@@ -15,6 +15,9 @@ namespace Infrastructure.Unity
[SerializeField] private float maxVelocityChange = 10f;
[SerializeField] private float snapForce = 15f;
[Header("Controls")]
[SerializeField] private bool useCameraRelativeMovement = true;
[Header("Interaction")]
[SerializeField] private LayerMask tileLayer;
[SerializeField] private float groundCheckDistance = 1.5f;
@@ -23,6 +26,7 @@ namespace Infrastructure.Unity
private InputSystem_Actions _actions;
private Vector2 _moveInput;
private Transform _camTransform;
public Rigidbody Rigidbody => rb;
public StatusManager Status { get; private set; }
@@ -48,6 +52,11 @@ namespace Infrastructure.Unity
_actions = new InputSystem_Actions();
Status = new StatusManager();
if (Camera.main)
{
_camTransform = Camera.main.transform;
}
rb.freezeRotation = true;
rb.useGravity = true;
}
@@ -66,20 +75,42 @@ namespace Infrastructure.Unity
private void HandleMovement()
{
var currentSpeed = moveSpeed * Status.CurrentCapabilities.SpeedMultiplier;
var targetVelocity = Vector3.zero;
var snapAxis = Vector3.zero;
if (_moveInput.sqrMagnitude > 0.1f)
Vector3 desiredDirection;
if (_moveInput.sqrMagnitude < 0.01f)
{
if (Mathf.Abs(_moveInput.x) > Mathf.Abs(_moveInput.y))
desiredDirection = Vector3.zero;
}
else if (useCameraRelativeMovement && _camTransform)
{
var camForward = _camTransform.forward;
var camRight = _camTransform.right;
camForward.y = 0;
camRight.y = 0;
camForward.Normalize();
camRight.Normalize();
desiredDirection = (camForward * _moveInput.y + camRight * _moveInput.x).normalized;
}
else
{
desiredDirection = new Vector3(_moveInput.x, 0, _moveInput.y).normalized;
}
if (desiredDirection.sqrMagnitude > 0.01f)
{
if (Mathf.Abs(desiredDirection.x) > Mathf.Abs(desiredDirection.z))
{
targetVelocity = new Vector3(_moveInput.x > 0 ? currentSpeed : -currentSpeed, 0, 0);
targetVelocity = new Vector3(Mathf.Sign(desiredDirection.x) * currentSpeed, 0, 0);
snapAxis = Vector3.forward;
}
else
{
targetVelocity = new Vector3(0, 0, _moveInput.y > 0 ? currentSpeed : -currentSpeed);
targetVelocity = new Vector3(0, 0, Mathf.Sign(desiredDirection.z) * currentSpeed);
snapAxis = Vector3.right;
}
}