- Home /
How to get the Y axis of an Object
Hi! Today I wanna ask how to get the rotation of y of an object, here is the small script I made
var fpscam : GameObject;
var lookDir : int = fpscam.transform.rotation.y;
function Update () { Debug.Log(lookDir); }
it doesn't seem to work. The output should be the rotation of the target in y axis but the Console constantly says 0 but I checked the Inspector and the Y is moving while Im moving the object
Thanks!
Answer by Alfrey_Cruz8133 · Jul 04, 2017 at 12:37 PM
I fixed it! I instead put the fpscam.transformrotation.y; to the Update Function
Answer by mnarimani · Jul 03, 2017 at 04:15 PM
First, you need to use float instead of int, if that didn't work and you didn't get what you expected, try getting EulerAngles:
var lookDir : float = fpscam.transform.rotation.y;
var lookDirEuler : float = fpscam.transform.rotation.eulerAngles.y;
Your answer
Follow this Question
Related Questions
Rotation angle from one object to another 5 Answers
Rotating a gameobject using integers 3 Answers
How do I stop objects from rotating when they collide 2 Answers
Flip over an object (smooth transition) 3 Answers
Orbiting objects appear stretched 1 Answer