Hi all,
I’m trying to create a rotation puzzle, where 4 objects need to be aligned to specific angles for the solution. There are 4 buttons that each rotate 2 objects 90 degrees clockwise.
Here’s the code for the Manager:
class RotationPuzzleManager (MonoBehaviour):
public listOfTwisties as (GameObject)
public rotationSolution as (Vector3)
def Execute (clickedObject as GameObject):
currentTwistieRotations as List = []
for eachTwistie in listOfTwisties:
currentTwistieRotations.Add(eachTwistie.GetComponent[of RotationPuzzleTwistie]().GetTargetRotation())
currentTwistieVectors as (Vector3) = array(Vector3, currentTwistieRotations)
if currentTwistieVectors == rotationSolution:
print ("YOU WIN!!!")
Where GetTargetRotation()
returns Quaternion.Euler(targetRotation).eulerAngles
and targetRotation
is where the Twisties are rotating to.
The angles are always right angles (0, 90, 180, 270) and the code above works… sometimes. Sometimes the comparison (currentTwistieVectors == rotationSolution
) fails when the angle is 0 or 180, eg ((0.0,0.0,0.0) == (0.0,0.0,0.0)
) OR ((0.0,180.0,0.0) == (0.0,180.0,0.0)
).
What am I doing wrong? Any help would be greatly appreciated.