How is AddForceAtPosition() _supposed_ to work?

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. :frowning:

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?

Well, you switched the order of the parameters…

Before I’m gonna try and break my brain at 3am on the rest of the code - try and put them in the correct order and post the results :slight_smile:

iSuck indeed! :wink:

Thanks for spotting the blatantly obvious error my brain failed to register! Changing the order of the parameters, things work as advertised now. Yay!

I think I’ll keep the implementation that uses RelativeForce and RelativeTorque, though.