Make objects appear at a certain time

Hello!

I have objects that spawn at the same time (in begin play) at diffrent positions, now i’ve included the notion of time.

I added a “current” time that is being updated (with event tick) and i want, according to the data i have about the objects , to figure out the best approach to spawn the objects based on their respective times, so that they spawn in the correct order.

Thanks

Set the time in a publicly visible variable on the actor

times

1 Like

Create a TMap where the key is the time and the value is whatever you want to schedule.
Update your time every second instead of on tick to save performance, and when the time updates check if the scheduled task time >= to the current time, if it is execute whatever you need to execute

EDIT: correction, instead of making the key of the TMap a time, make it a start time and end time struct, and check if the thing to spawn is within the start and end time, this way if you skip a day you don’t get a bunch of random stuff happen and things will execute only within their timeframe

1 Like