Rigidbody Stop when no key pressed
Hello, I've tried transform.translate, but it's collision is kinda wacky. So I'm gonna have to add force, but when I add force my character just glides for a few seconds before stopping. I want collision, but when I take my finger off the key I want my character to stop straight away.
PS. I use WASD to control my character so If all these keys aren't pressed
I've tried rigidbody.moveposition but I can't move diagonal
Answer by jgodfrey · Jun 05, 2016 at 07:12 PM
You probably just want to set the Rigidbody's "velocity" member to zero. So, something like:
myRigidBody.velocity = Vector3.zero;
Additionally, you might want to zero out the angular velocity too...
myRigidBody.angularVelocity = Vector3.zero;
Your answer
Follow this Question
Related Questions
2D Characters slowly drifts downwards? 1 Answer
Character is going left when i start the game, 0 Answers
Best way to move an object smoothly 2 Answers
player getting stuck when moving. 1 Answer