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!

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;

I fixed it! I instead put the fpscam.transformrotation.y; to the Update Function