using player.rotation?

Hi, I am needing to checking the rotation of my player to use it to change a few things. Currently I have this set up but it seems to be returning nothing higher than 1. I have seen a few places mentioning that I need to use quaternion.euler, but I am not sure how I would use that to get the rotation. currently I have

playerYPos = transform.rotation.y;

How could I use this and convert it into a quaternion?

You don’t convert it into a quaternion, player.rotation is a unit quaterion ^^. You could convert it to euler angles which is probably what you’re looking for.

transform.rotation.eulerAngles.y

However this is kind of unreliable. Unity does not store rotations as euler angles but as quaternions. There are multiple euler angles combinations that result in a certain rotation. Since when reading eulerAngles those are calculated backwards from the quaternion, the resulting angles may not represent what you think they are. The 3 angles belong together. They could flip at unexpected times by 180° but would still be valid.

There are usually other ways to check the player rotation. However since you just mentioned quite unspecific “few things” we can’t really suggest something else ^^. Maybe you should be more clear what you need for what purpose. Also keep in mind depending on the kind of game, rotations may have different constraints. For example most FPS games always have the world up axis represent up and everything happens in a certain orientation, gravity is down, etc. However there could be games where such constraints are not given (think of space games with full 3d freedom like in space engineers). Here it would be much harder to specify a certain orientation. Without knowing the exact setup and requirements it’s difficult to give clear instructions.

Hi thanks for the reply, I will try out that code.

The reason I am wanting the rotation is to do with playing animations. My player works off of the camera angle, and faces towards the mouse, so I am trying to use the way the player is facing to determine what animation to play. I was going to do something a long the lines of between 35 and 125 play a certain animation, between 125 and 190 another animation etc etc.