I copied a moving system from YouTube to improve my chrecter movement. But the chrecter always moves a little and then stops and I dont know why. I think it might be connected to the X velocity in the rigidbody because the charecter always stops when the velocity drops to 0.
This is the script:
Speed = _moveInput.x * MaxSpeed;
if (Input.GetKey(KYBRight))
{
IsFacingRight = true;
IsMoving = true;
float SpeedDif = Speed - rigidbody2.velocity.x;
float movement = SpeedDif * accelaration;
rigidbody2.AddForce(movement * Vector2.right);
print(movement);
}
And here’s a video of the problem: