Referencing world vs local space with transform.rotation

Hello,

In my program I am trying to make a lever that controls the flow of water. When the lever’s rotation is within a certain range of angles, a particle system should be active. When it is outside of that range, the particle system should stop. I also have the lever’s rotation restricted to only move within a 90 degree range, the “on” range is about 20 degrees.
My issue is that in my code, the euler angles I am referencing are based on world space, not the object’s local space, and it feels like a guessing game trying to find the correct range. Is there a better workflow for finding these kinds of values?

Hello, I didn’t quite understand what you wanted to do but I saw in the documentation that Transform.eulerAngles represents rotation in world space. When viewing the rotation of a GameObject in the Inspector, you may see different angle values from those stored in this property. This is because the Inspector displays local rotation. Transform.localEulerAngles is the rotation as Euler angles in degrees relative to the parent transform’s rotation. Maybe this can help you.

I second the above answer with local euler angles but since you have 2 states on that lever (on and off), shouldn’t you just animate it, based on its state on or off? or do you need to control the water’s level based on how far off the lever is?