Search Unity

Vector3 and Quaternion help

Discussion in 'Scripting' started by StarManta, Oct 26, 2006.

  1. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    I'm trying to rotate a Vector3 around the y axis by 1 degree. I've created the rotation to use for it:
    var leftTurn= Quaternion.AngleAxis(-1, Vector3.up);

    But I can't seem to find any function that rotates a vector by a quaternion. Is there such a function? It seems like such a basic function, I find it hard to believe it would be in neither Quaternion or Vector3, given how function-complete Unity generally is. Which leads me to suggest I've missed it.

    http://unity3d.com/Documentation/ScriptReference/Quaternion.html
    http://unity3d.com/Documentation/ScriptReference/Vector3.html
     
  2. Morgan

    Morgan

    Joined:
    May 21, 2006
    Posts:
    1,223
  3. freyr

    freyr

    Joined:
    Apr 7, 2005
    Posts:
    1,148
    You rotate a Vector3 by a Quaternion by multiplying them together. The result is the rotated vector.

    See the second version of: Quaternion.operator *
     
  4. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Ah thanks freyr!