- Home /
Question by
Sipondo · Mar 02, 2012 at 09:30 PM ·
raycastvector3quaternionvectormain camera
Vector based on the rotation of the main camera
Hey everyone!
I have a question regarding calculating a vector based on the rotation of my main camera. I have been looking around on unityAnswers and found what I thought was the correct way of doing this, however an error occurs when I try to execute this script:
var rot = Quaternion.Euler(Camera.main.transform.eulerAngles);
var yangle = Vector3.forward * rot;
I want to use the resulting vector in raycasting. The script I wrote for that purpose does works without any problems when I use the standard forward vector.
Thanks a lot!
Comment
Best Answer
Answer by Berenger · Mar 02, 2012 at 10:11 PM
rot Vector3.forward, not the other way around (Quaternion Vector3)
However, this is going to give you Camera.main.transform.forward, so it's not really necessary. And Quaternion.Euler(transform.rotation.eulerAngles) == transform.rotation.