I am trying to get the y value of the transforms rotation for a gameobject with name “turret”
i tried to use a code (c#) like this to do it, but the values it gives me are obviously wrong, telling me it is 30 when it should be 90.

float ang = GameObject.Find(“turret”).transform.rotation.y;

I’m not sure if this is enough information for anyone to help me, but please help! Its bothering me that I can’t seem to fix this.

“transform.rotation” is a Quaternion and you should not use the x,y,z,w values directly unless you understand Quaternions. Use transform.eulerAngles instead.

They’re not wrong at all. Transform.rotation is a 4D quaternion, which does not use degrees, nor do the x/y/z elements directly correspond to the x/y/z axes. You can try using Transform.eulerAngles, but reading one particular axis doesn’t necessarily give results you might expect either since there’s more than one valid way to convert quaternions to eulerAngles.