I am currently developing a NASCAR driving simulator game, and I can’t get the cars to move in the direction that they are facing. I am using physics and this.entity.rigidbody.applyForce and this.entity.rigidbody.applyTorque. After applying torque, and changing direction of the object, the object still continues to increment only it’s Z axis coordinates, and moves in a different direction. Please help!
You are applying force along the world Z axis as apply force is applied in world space. You would want to apply force along the entity’s forward axis.
// Get the forward direction of the entity
var forwardForce = this.entity.forward.clone();
// Scale the direction by the amount of force you want to apply
forwardForce.scale(7);
// Apply the force
this.entity.rigidbody.applyForce(forwardForce);