My aim was to simulate an object being propelled by a thruster, so I wrote:
var m_thrusterPos : Vector3(0, 0, -1); // local-space thruster position
var m_thrusterForce : Vector3(0, 0, 500); // thruster force in local-space
function FixedUpdate()
{
var wPos : Vector3 = transform.TransformPoint(m_thrusterPos);
var wForce : Vector3 = transform.TransformDirection(m_thrusterForce);
rigidbody.AddForceAtPosition(wPos, wForce);
}
On pressing run, I expected my object to start moving under the force of the thruster. Instead, it just sorta kinda sat there. Not moving. At all.
After trying a bunch of different things, I got it to move the way I expected by doing this instead:
function FixedUpdate()
{
rigidbody.AddRelativeForce(m_thrusterForce);
rigidbody.AddRelativeTorque(Vector3.Cross(m_thrusterPos, m_thrusterForce));
}
I’d expect this to be equivalent to the version I wrote above, except it’s not. So… what am I missing here? How is AddForceAtPosition supposed to work?