Hi there! I’m working on a game where the longer the player stays moving the more they accelerate and I made this code to to check if player is moving above a certain speed.
void FixedUpdate ()
{
if (player.velocity.magnitude >= 2)
{
print("true" + player.velocity.magnitude);
player.AddRelativeForce(Vector3.forward * 1.5f * Time.deltaTime);
}
else
{
print("false" + player.velocity.magnitude);
}
}
However player.velocity.magnitude always returns zero (I’ve also checked if player is equal to the correct Rigidbody and it is)
I searched a bit online and apparently it’s something about the FPCharacter altering the speed directly so the Rigidbody doesn’t know the speed, yet none of them gave an alternative of checking the speed.
Is there even a way to do this?
All help appreciated ![]()