Hi,
I don't know enough about PhysX (or actual physics!) so was wondering if someone could help me out.
I'm trying to create some simple spaceship controls on a rigidBody. I am doing this by using AddForce to add a direction vector and move the ship accordingly. The problem is (rather obviously), once I have added the force, it stays in effect endlessly. I obviously need to add some kind of resistance to the ship so that after I move in a direction, it slowly comes to a stop (which is specified by the resistance variable or whatever.)
Firstly, is using AddForce the wrong thing to do? Secondly, can anyone suggest a method in which I could apply resistance to my equation:
var directionVector = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
if (directionVector != Vector3.zero) {
var directionLength = directionVector.magnitude;
directionVector = directionVector / directionLength;
directionLength = Mathf.Min(1, directionLength);
directionLength = directionLength * directionLength;
directionVector = directionVector * directionLength;
}
gameObject.rigidbody.AddForce(directionVector);