Search code examples
unity-game-enginegame-physicsmovephysicsrigid-bodies

Have fixed speed with AddForce?


I want to use AddForce to move an object with a fixed speed but when I use AddForce the speed of the rigid body increases in crescendo. AddForce adds a force to me every time I hold the input down, the more I hold the key to move the object the more force is added, while I always want to move the object with the same force.


Solution

  • You may set the velocity directly instead of adding accelerated force every frame you hold down the button. So instead of using AddForce(), you can access your rigidbody's velocity like in this example.