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 *.
exactly what i was looking for :)
Answer by Bampf
Jun 23, 2010 at 10:57 AM
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:
Here is a link to the documentation.
First link is now broken :(
All Links broken. Thanks unity!
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
2 People are following this question.
Instantiating relative to rotation of object
Set rotation based on 1,1,1 style vector? How to convert vector3 to quaternion?
Add vector according to objects's local position & roation
Calculate Quaternion.LookRotation manually
Get rotation from hit object