Hi,
I’m trying to throw together a simple character controller, building it around a rigidbody and applying forces to it to make it move (I want a character controller that interacts with basic physical elements).
So far I can get it to move fine with
function Update ()
{
rigidbody.AddForce(Vector3.forward * Input.GetAxis("Vertical"), ForceMode.Impulse);
}
which adds whatever the value of the W/S key axis (1 for ‘W’, -1 for ‘S’) as a force. But of course, here there is no limit to the force, and the player can accelerate endlessly if they hold down the movement keys.
After trying to make a sort of force-counter which accumulates once every loop if force is being applied, and stops force from being applied if it reaches 10, I’ve decided that I really need to track decreases in the momentum of my character controller as well as increases. But simply tracking player velocity seems like it might cause a problem; it also sets a limit to how quickly the wind-mechanic of my game can blow the player about. What I need to do is precisely track the force applied from player-input alone, regardless of other forces and the consequent velocity
So I’m a little stumped. Can anyone help?