- Home /
Rotate a vector relative to itself
I have a plane defined by transform.forward
and transform.right
, with 0 degrees corresponding to the forward vector and positive 90 degrees to the right vector.
How can I create a third vector rotated in this plane. A rotation of 0 degrees would mean the vector is identical to transform.forward
, a rotation of 30 degrees would mean it forms a 30 degree angle with the forward vector.
In other words, I want to rotate the forward vector relative to itself, in the plane it defines with the right vector.
Answer by whydoidoit · Jun 20, 2012 at 09:22 PM
You need to rotate it around the cross product vector - in this case it will be transform.up - which means this documentation has an almost exact example :)
var newVector = Quaternion.AngleAxis(30, transform.up) * transform.forward;
Your answer
Follow this Question
Related Questions
How to smoothly rotate to certain directions using input axis 1 Answer
transform.LookAt boundaries 1 Answer
How do i lock the position of the camera above the player relative to the origin point? 0 Answers
Make a side of an object LookAT another object 1 Answer
nullifying targetObject after a Smooth LookAt Transition 2 Answers