- Home /
is it possible to use a rotation on a Vector3?
Hi,
is there a quick way to change a vector3 with a rotation without having a GO? Ive got a Vector3(X,Y,Z) and want modify this Vector with a Rotation(X,Y,Z) as if it were a GO. Or do I need to have a GO, place this at Vector(X,Y,Z), do the rotation and then read the Vector3 values?
Answer by StephanK · Jun 23, 2010 at 10:54 AM
You can do this:
Quaternion rotation = Quaternion.Euler(x,y,z);
Vector3 myVector = Vector3.one;
Vector3 rotateVector = rotation * myVector;
It's important that the Quaternion is on the left side of the *.
Answer by Bampf · Jun 23, 2010 at 10:57 AM
Yes.
The preferred way is to use Quaternions. Conceptually (mathematically) they are a bit intimidating, but if you treat them as a black box that stores rotations, they are pretty easy.
See the first example in this forum thread to see how easy it is: http://forum.unity3d.com/viewtopic.php?p=303861
The link is broken down... Now there is an option showing for Book Of the Dead...LOL