system
1
I move a game object in the XZ plane by using the Translate
Vector3 startVector = new Vector3(1,0,0);
void Update(){
transform.Translate(startVector *1f*Time.deltaTime);
}
How add or subtract 30,45 degrees to the startVector and get endVector.
I read the FAQ by Quaternion, but did not understand how to do it.
can anyone give an example?
![1]
[1]: http://imageshack.us/photo/my-images/13/vectm.jpg
Peter_G
2
You can multiply a Vector by a quaternion. In your case, you just need to do something simple:
var startVector = Vector3.right;
var endVector : Vector3 = Quaternion.AngleAxis(degrees , Vector3.up) * startVector;
transform.Translate ( endVector * Time.deltaTime);
AngleAxis() constructs a quaternion rotated x degrees around a vector. Then we can multiply the vector by the quaternion to get the end result.