#How to rotate to look at a direction with PhysicsVelocity?
1 messages · Page 1 of 1 (latest)
neither do i have access to ".eulerAngles"
I recommend taking a look at the implementation of PhysicsVelocity.CalculateVelocityToTarget, it might show you what you need 😄
Here's the interesting part for you:
var worldFromBody = new RigidTransform(bodyOrientation, bodyPosition);
var worldFromMotion = math.mul(worldFromBody, bodyMass.Transform);
var motionFromWorld = math.inverse(worldFromMotion.rot);
var angularVelocity = math.mul(targetTransform.rot, math.inverse(worldFromBody.rot)).ToEulerAngles() * stepFrequency;
requiredAngularVelocity = math.rotate(motionFromWorld, angularVelocity);
Where bodyOrientation and bodyPosition is your current pos and rotation. targetTransform.rot is your desired rotation (you can replace this with a quaternion using something like quaternion.LookRotation(...))
stepFrequency is 1/FixedDeltaTime. bodyMass.Transform is well, your PhysicsMass.Transform :3
ok i will be experimenting with this. TY
No clue if it helps in your sittuation, but as they say 'discovery requires experimentation' 😛