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!
Are you applying force along the entity’s forward vector? Can you show the code/post a link to the project please?
this.entity.rigidbody.applyForce(0, 0, 7);
Sorry, didnt copy the closing }bracket
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
// Apply the force
Thanks so much, I’ll try this
Does the same thing work for backward?
Scale the vector by a negative value to go backwards.
OK, thanks a lot @BenBean303 and @yaustar!