Can anyone show me how to get the position (translation) of a RigidBody given its handle?

can anyone show me how to get the position (translation) of a RigidBody given its handle?

Hi!

Iā€™m assuming you use a version of nphysics >= 0.12.
Let body_set your set of bodies of type DefaultBodySet, you can do:

// Get reference to the rigid body.
let rigid_body = body_set.rigid_body(handle).expect("This rigid body does not exist.");
// Get the position (containing both translation and rotation).
let position = rigid_body.position();
// Read the translation vector itself.
let translation = position.translation.vector;
1 Like

Hi sebcrozet,
Thanks, this is exactly what I needed!