romcioPaluszek Posted July 2, 2020 Share Posted July 2, 2020 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
karpych11 Posted July 3, 2020 Share Posted July 3, 2020 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; 1 Link to comment
Recommended Posts