Can't get Make Date And Time struct to work

Hello Dev Community,

I need to get the date and time tracked for a game I’m prototyping. I managed to get Days Hours Minutes and Seconds working but I want to add months and years. My current set up has Make Timespan which is working fine.

However when I swap out the Timespan for a ‘Date and Time struct’ it stops working.

I connected up a ‘Break Date Time’ and Printed the Minute result which is 0. This works on the Make Timespan struct.

If anyone has encounter this problem or knows what might be wrong I would love to hear know more.

Cheers
Ben

Hey @BenP3D!

So instead of that “Set: Date and Time” node there, what you need to use is “Set Members of struct”. What you’re doing is telling it the TYPE of struct to use, I know, it’s a bit different.
But that’s how you can change an overall struct layout, then you use “Set Members” to set the individual pieces of the struct’s variables :slight_smile:

Hey Mind-Brain,

Thanks for the reply.

Sorry I don’t know much about item structures. Could you elaborate further as I’m having trouble replacing the Make date Time node with the Set members of struct.

Cheers
Ben

Ah, you’re trying to replace the wrong node :stuck_out_tongue: You want the Make Date Time node to stay.

This is the node you’re replacing:
image

Ah I see. I gave that a go and I’m still having the issue of when the truncated value gets plugged into the make date time node it spits out 0.

This is what the set up looks like now.

Thanks for your help so far. I really appreciate it :slight_smile:

Let’s trace it upwards a bit.
Can you show where you’re calling this? What blueprint it’s located on, if it’s on tick or a timer, etc? Thanks!

It’s a Function that’s attached to a custom event that runs the day night cycle. It has a delay of 0.01 then calls the day night custom event again.


(Track Time F is where the Time and date is being tracked)

Ok, nearly there! Where is this originally being called? On beginplay somewhere?

Ah yes event begin play is where it’s being called first.

Okay. So it looks like you’re right, from start to finish, the whole thing looks pretty well set up. So testing is in order.

Printstrings. I’d throw some:

on DayNightCycle, after the delay and before the end. Call it anything unique.
Added test: set the delay ticks to .3 and watch to see if the delay’s just too fast.

Before, AND after the Set Members in DateAndTime Struct. First one use the “Seconds” FLOAT. Second one, plug in your minutes from make date time.

This should help give some insight on WHERE the issue is.

1 Like

Hey Mind-Brain,

I went through and did the steps you suggested. The thing that is giving me some results is changing the delay form 0.001 to 0.3. When I print string after the "Set Members in DateAndTimeStuct it does spit out some numbers up to 59 once then goes back to 0. If I change the delay to any number lower than 0.3 it goes back to only returning 0.

This is what’s getting printed before it goes back to 0
image

It seems that updating too fast is breaking it somehow.

Thanks for sticking with me on this one.

OK! So the issue with the number skipping has to do with your time math. If you want it to be seconds=minutes, just use an Int for seconds, and +1 at the start, with a delay of 1.0 at the end. Then you’ll want to, before adding everything to the make date/time, do any conversions:
If Minutes = 60, +1 hour, set Minutes = 0 and so on.

1 Like

Hey Mind Brain,

Thanks so much for the help. I managed to get things working!

Cheers
Ben

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.