My movement works perfectly with WASD, but when using gamepad my character stutters and behaves strangely, same code.
No idea what could be causing this?
public void ExecuteLogic()
{
var movement = InputManager.Input.Basic.Movement.ReadValue<Vector2>();
player.movementDirection = new Vector3(movement.x, 0, movement.y).normalized;
if (!player.overrideRotation)
{
// Rotate the character to face the movement direction
if (player.movementDirection.magnitude >= 1f)
{
Quaternion targetRotation = Quaternion.LookRotation(player.movementDirection);
player.transform.rotation = Quaternion.Lerp(player.transform.rotation, targetRotation, Time.deltaTime * player.config.rotationSpeed);
}
}
// Movement
if (player.movementDirection.magnitude >= 1f)
{
player.characterController.Move(player.movementDirection * Time.deltaTime * player.config.movementSpeed);
}
// Always ground character, some rare occasions collisions will cause it to levitate
player.transform.position = new Vector3(player.transform.position.x, player.groundY, player.transform.position.z);
}