Jump to content

Linear and angular velocity relative to bodyrigid


photo

Recommended Posts

I would like to ask, how to get velocity vectors relative to rotation of node or bodyrigid. I mean, that if vehicle is going forward I will get for example vec3 (2.5, 0, 0). If this vehicle turn to right or left and speed will be same, I will get same vector.

Link to comment

Hello,

To get the linear velocity of rigid body in local rotation of an object, you must multiply this velocity by the inverse world rotation of the object:

vec3 localVelocity = MathLib.Inverse(node.GetWorldRotation()) * node.ObjectBodyRigid.LinearVelocity;

And if you need to apply the speed in local rotation to rigid body, then this velocity must be multiplied by the world rotation of the object:
 

vec3 localVelocity = vec3.FORWARD;
node.ObjectBodyRigid.LinearVelocity = node.GetWorldRotation() * localVelocity;

 

  • Like 1
Link to comment
×
×
  • Create New...