I’m trying to move my character by applying force. Going forward works good, but i have problems when i try to make it move sideways by applying a ‘left’ force to it. Then my model shoots up in the air and my it spins like a ballerina…
Anyone any idea what the problem could be…??
Here’s my code:
// FORWARD
if ( Input.GetKeyDown ( KeyCode.W ) || this.forward )
{
this.forward = true;
this.model.rigidbody.AddRelativeForce ( this.model.transform.forward * 100f, ForceMode.VelocityChange );
}
if ( Input.GetKeyUp ( KeyCode.W ) )
{
this.forward = false;
this.model.rigidbody.velocity = Vector3.zero;
}
// LEFT
if ( Input.GetKeyDown ( KeyCode.A ) || this.left )
{
this.left = true;
this.model.rigidbody.AddRelativeForce ( -this.model.transform.right * 100f, ForceMode.VelocityChange );
}
if ( Input.GetKeyUp ( KeyCode.A ) )
{
this.left = false;
this.model.rigidbody.velocity = Vector3.zero;
}