Hi,
*Edit: I’ve changed my question as I need to rotate an object smoothly through just one axis, and realise that I am probably going about this in the wrong way by using Quaternion.Slerp, etc. Any advice on how to achieve this is most welcome. I have still left my original question below to give you a picture of where I’m going wrong.
I’m rotating an object with Quaternion.Slerp, and then checking if it is finished by using Quaternion.Angle. and using an if statement to check if it’s reached its destination. Once it reaches its destination it will stop trying to Slerp to it. My problem is that I only need to check one or two of the axes (it should just be the one axis I need to check if my logic serves correctly!)
My code is simply this:
if(Quaternion.Angle(toUpsideDown.rotation,transform.rotation) == 0){
FinishedRotation();
}
How can I isolate/exclude individual axes from Quaternion.Angle? I only want to know when the x and y have reached their destination, I don’t want it to wait for z as well as this causes behaviour that I don’t want (I want it to keep facing the same direction when it is rotated, no matter where it is looking - not be forced to turn and face north, for example)
My destination in Quaternion.Angle is a Transform variable (called toUpsideDown as the object is rotated to be upside down), and to use it I drag an empty GameObject into the inspector which is at the right orientation.
If I cannot achieve this with Quaternion.Angle, what other methods can I use?
Thanks!