x


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?

more ▼

asked Jun 23 '10 at 10:22 AM

Ent gravatar image

Ent
76 12 13 20

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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 *.

more ▼

answered Jun 23 '10 at 10:54 AM

StephanK gravatar image

StephanK
6k 40 53 93

exactly what i was looking for :)

Jun 24 '10 at 09:02 AM Ent
(comments are locked)
10|3000 characters needed characters left

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

Here is a link to the documentation.

more ▼

answered Jun 23 '10 at 10:57 AM

Bampf gravatar image

Bampf
5.1k 8 20 49

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2249
x602
x499

asked: Jun 23 '10 at 10:22 AM

Seen: 1461 times

Last Updated: Jun 23 '10 at 10:22 AM