okay so ive set up a day n night cycle but im using delta time. i want a variable to be for example in minutes so if i set the varible to 1 that will equal to 1 min. so the day will last 1 min, also i want to calculate the degrees on the sun. Im wondering if anyone knows how to do this.
doesn’t sound difficult
(Interval - (time delta % interval)) / interval * 360
Should work… If not, show what the blueprint/code looks like and I’ll see if I can test
sorry im new to this kind of stuff, but what does interval mean what is it? and i made a clock without the need of delta seconds and only with ingame seconds. but there is some bugs with the new system i made
years : months : days : hours : minutes
what i have now
what i used before
The Degrees are plugged into the Pitch so you can promote the result of * 360 to a variable if you need. You can use your in game seconds instead of the delta seconds from the event tick. You may need to use SetActorRotation instead of Add but if you set the rotation on startup then the above will work fine
For the clock:
GetGame seconds → make new variable.
get years(trunc(GameSeconds / yearseconds)), subtract years*yearseconds from new variable.
repeat for days, hours, minutes
x = gameseconds;
Years = trunc(x / yearseconds)
x=x-years * yearseconds
repeat for months, days etc.
Otherwise look at the MakeDateTime function within unreal
this did not work with delta seconds but it worked with get time seconds. it made my script much cleaner and more efficient. thanks mate
as of the clock i dont understand what im doing wrong
Here’s probably what you want. If so, hit the ‘like’ button
You can multiply the GetTimeSeconds result by (secondsinaday / DayDurationSeconds) for your in game time
kinda, like i want it to go from 12 am to 12 pm if you know what i mean. so if the sun is 90 degrees its 12 noon.
just set the Pitch rotation of the directional light to 90.
This starts it at midnight. If you want another offset, you can plug in some other numbers
Knowing that midnight is 90, time = mod(360 / (SunAngle - 90)) * 86400 I think
but you should have all the values if you are using the above code. If you start your sun at a different angle, you will need to provide an offset to the GetTimeSeconds function (or just pause the sun using an event and print out the angles etc.)
i think i got it to work now. Thank u for taking ur time mate
oh yeah one last thing when i have months etc and i want it to start on 1 or 4 etc how do i do that?
Glad you got it working Looks good. I tested with a day duration of 20 secs - easy if you have it set as a variable.
so that’s the final clock, takes the initial sun angle and uses it to set the start time. To do years etc. just do a MakeDateTime and add the time span that you use to generate the printout. Or if you want months to be fixed length (maybe you have your own calendar) then
month = trunc(time / monthDurationSeconds) % 12 + 1
Years = trunc(time / YearDurationSeconds)
or you could use the days output whatever suits
If using MakeDateTime, you can set that up with starting values, otherwise, you can add to the TimeOffset variable
Glad I could help
Some time ago I made a C++ plugin that does this. Check it out if you want GitHub - jonimake/CelestialSphere
Thank you so much for the help i really appreciate it