If I add a force using the AddForceToPosition method and that force is off-centre, then it causes both movement and torque to the rigidbody. What is the best way to maintain the position of that force as the rigidbody rotates?
public Vector3 pos=new Vector3(0,0,40);
public Vector3 forceXYZ=new Vector3(0,0,0);
void FixedUpdate () {
rigidbody.AddForceAtPosition(forceXYZ, transform.position - pos);
}
This simple code does not take into account the rotation of the object, so the force is always being applied at 40 world-space units from transform centre. I want to maintain the force’s position WITHIN the object’s local coordinate system.
This seems to be a fairly obvious application of this method, but I’ve been unable to find examples…
Cheers
Jason