Texture rotation resets after full rotation

Hi all,

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?



24( this is the 0 state)
23(this is just before full rotation

hope someone can help! thank you!

Someone know why this happens? it rotates the z from 0 to 180 is there a way to lock this? it is the directional light

Which direction your are spinning?

I think it’s your time of day comparison.

If time of day crosses midnight, it’s resetting to 00:00:00, which is before Dusk.

The comparison should be (TimeOfDay > Dusk) OR (TimeOfDay < Dawn)?

hi!

i made it somewhat easier to put the moon cycle on a 24 to 48 hour , the sun goes from 0 to -180 and the moon goes to -180 to 0


so what i see is that after hour 37 the moon directional light suddenly flips from 0 to 180


up image is time of day 35

down image is 37 and rotation z is suddenly 180


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

plz see comment above

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?

Thank you for your answer, i will try this and get back to you!

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 :




when i put the blueprint in my scene and go to the 0 time:

then i see the directional light on 180 on the z rotation axis

then when i go to a half point like day of time 12:

the directional light suddenly goes to - 180 on the z axis :

very weird that this happens

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.

its maybe something with the engine because i now set the range like this 0 to 360 and i do set the world rotation now:


now on the time of day 180

the direction z axis is -180

if i place the world time on 181 :

exactly after the half point the direction z axis goes to 0:

every halfpoint (highest in the sky point) it changes to negative or 0

very weird