- Home /
Predict Vector after AngularVelocity applies
I just know this should be straightforward, but I cant find what I need in the objects.
Given a rigidbody which is rotating on the spot. I can get it's angular velocity and its current transform.forward easily enough, but I want a function that will let me rotate transform.forward by (angularvelocity x t) so I can predict what the objects forward vector will be assuming that the same angularvelocity continues to apply for the next t seconds. and, importantly, I want to do it WITHOUT actually rotating the transform. So transform.rotate is out. I want to predict it, not change it.
(Ignore angular drag for the moment, I just want a simplest case.)
I think I'm just missing the right Vector3 function or something but I get confused because angularvelocity is a vector not a quaternion.
Any help is appreciated
Answer by robertbu · Jun 26, 2013 at 06:44 PM
This is untested but should work:
var v3NewForward = Quaternion.Euler(rigidbody.velocity * t) * transform.forward;
't' is the time in seconds.
Perfect thankyou. I knew it would be something simple, but I didn't realise you could multiply a quaternion and a vector with a simple * operator.
Also, in case anyone else comes across this. It's worth bearing in $$anonymous$$d that rigidbody.angularvelocity is in radians but rigidbody.addtorque and quaternion.euler take their parameters in degrees!
Radians. It would be nice for the script reference to mention this.
Your answer
![](https://koobas.hobune.stream/wayback/20220613104921im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Stop velocity on rotation change 2 Answers
PS3 Move.Me : angularVelocity to local space 0 Answers
Aligning a transform according to two different positions and directions 1 Answer
Gravity on a rotating platform 1 Answer
C# - local angularVelocity 1 Answer