Reputation: 1723
I've seen quite a lot of questions like this, and the trouble is - the question makes no sense. They are not the same thing, it is a bit like saying "how do I convert an apple into a brick"?
But usually the underlying question does make sense, it is the wording that is suspect.
What I want to do is this:
Now, I think the answer is
Vector3 ans = R * Vector3.forward;
Is this right, and if so, why? (If not right, then what is the answer?)
Upvotes: 5
Views: 16983
Reputation: 90580
Yes that is correct.
Quaternion * Vector3
takes a given vector and rotates it according to the given rotation.
So if your R
is basically the object's world-space transform.rotation
then the result will be the objects local forward (positive Z) vector as a vector in world space coordinates.
You can also directly use the object's transform.forward
vector which basically equals transform.rotation * Vector3.forward
Upvotes: 9