Why can’t I use the greater than or less than here and how can I fix it.
,My Script -
if(transform.rotation >= Quaternion.Euler(0, 0, -1f))
{
FacingRight = true;
} else {
FacingRight = false;
}
The error is that you cant use >= or <= when using Quaternion So how can I fix that
Hey there,
a quaternion is a 4-D Vector. It is kind of difficult to use a greater/smaller than operation on any kind of vector.
So assuming that you want to check if - let’s say your player object - is facing left or right you could choose from some methods but that all depends on your exact setup.
For example you could check for the euler angles that you get from your transform.rotation but this is kind of flawed if you do some more complex rotations.
Best would be if you specified a bit more information about your project.
If you want to see if an object is aiming higher than something. You gotta use local direction vectors not Quaternions, not Euler angles. Reason is that if you use Euler angles, the pitch and roll can represent the same “up” direction. So if you use a local direction vector, you can just check how high the y component is. Then go from there.