I’m trying to provide a unit with a floating health bar. To keep the health bar horizontal while it is the child of that object, i subtract the objects rotation.eulerAngles.z from 360. This gives me the appropriate numbers to keep the health bar rotated in such a way that it is always horizontal. It was not working, I kept getting the inverse rotation for some reason. I did some debugging and the numbers showing up in the code where different than the ones showing up in game. I even eliminated the math and just set the rotation with a constant.
No matter what the rotation is set to in the code it seems to be set to the inverse of the difference of 360 minus that rotation in game.
If I set the rotation to (0,0,350) in code, in game it’s (0,0,340). 360 - 350 = 10. The inverse rotation of 10 is 340.
If I set the rotation to (0,0,270) in code, in game it’s (0,0,180). 360 - 270 = 90. The Inverse rotation of 90 is 180.
What is going on here, and how do I fix it? I’m completely baffled.