I have a day and night cycle but when the moon reaches 24(midnight) then it suddenly resets the rotation to the 0 position. how can i change this so that the moon rotates to the 0 position?
the same thing happens with the sun at the highest point it suddenly flips on the rotational z 180 degrees. but you just cannot see it because it has no texture
So I’m not going to wire all this up and test it, but I certainly have had problems with rotations and Unreal making the equivalence that -180 = 180, that -10 = 350, etc.
So can you try adjusting your ranges, instead of 0 to -180, and -180 to 0, doing 360 to 180, and 180 to 360?
Hey i tried it but it is the same at the half point the directional light suddenly turn to negative.
i made a new blueprint with only sky atmosphere and a directional light an on the light with the property Forward Shading Priority on one, i changed nothing else.
then i just made a float with the range of 0 to 24 and the following components that fire from the constructor script :
I’m not sure what the problem is, but I still think one problem is your range of 0-24 mapping (now) to 180 to 360; if your value rolls over from 24 back to 0 at midnight, the rotation will snap back to 180.
The other thing is I feel like you shouldn’t be “adding” instead of “setting” the world rotation.
If you’re trying do do a lunar cycle. you should probably keep track of the number of days elapsed. Like wherever you flip time of day from 24 to 0 in tick, increment (++) a “day number” int var.
Then when you set moon directional light’s pitch do math on day number * or / by delta time/day length (basically same math as setting Time of Day) to figure out moon “time.” Plug that into a map range with out min 0 and max of (number of days in lunar cycle)*360 , or cheat and use 10800 for a 30 day cycle. Plug that range output into pitch. Engine should track the extreme pitch value and auto map it to 0-360.