- Home /
Calc 30° left and x units forward from local forward axis
I have a GameObject (GO) named X and it is rotated somehow. Now, I want to calculate the position and orientation for another GO named Y, that shall be 30 units away and 30° left measured from the local Z forward axis. Can anyone help me on this?
Thanks!
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by robertbu · Jun 10, 2014 at 01:38 PM
You can get the position this way:
 var dir = Quaternion.AngleAxis(30, transform.up) * transform.forward;
 var pos = transform.position + dir * 30;
From your question, I don't understand the orientation. You might want:
 var rot = Quaternion.AngleAxis(30, transform.up) * transform.rotation;
Brilliant, thanks for the quick answer, that solved it!
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                