I got my character to move using forces instead of translate, but turning doesn’t stop when I release a or d. Same goes for forward-backward movement. How do I stop the character when buttons are released?
You can do it a few ways:
- Increase the linear damping so that if no force is applied to the character object, it stops moving pretty quickly. (This is what the first position project sample uses from PlayCanvas)
- Use velocity instead of forces to move the character. So when no key is pressed, the velocity of the character is set to 0 (or you can change it so that it decreases over time)
- When no key is pressed, apply a counter force (a braking force if you like) until the character stops moving