Hi!! I need some suggestions on a system I came up with lately.
I’m making a top down dual stick shooter, nothing too extravagant. A particularity of this game is that it has slow motion moments where I don’t want to just do global time dilation to everything, since I might desire to have some things be slomo and some not in the future, or whatever I please.
So basically anything that moves in the world is naturally multiplied by delta seconds, and THOSE delta seconds are multiplied by a “Real Time Speed” variable that is by default 1 (does nothing by default), and is modified sometimes by a condition. (physics objects each get a custom time dilation by this variable)
What happened is that now I wanted to create a grenade that explodes after X seconds, say, 4.
But I cannot simply make a delay of 4 because if time speed changes in between, it wouldn’t update. Same thing with timelines since as far as I know you can’t change the time values on the run.
So what I did was to add delta seconds every frame to a variable called “Clock” (default 0), and these delta seconds are multiplied by this Real Time Speed so that it would get to those 4 seconds when it actually should despite the time.
Then, when it reaches a variable called “Fuse” (x seconds), it triggers.
Event tick is demonized because people tend to put there everything from unnecessary calculations to spawning actors and other performance heavy functions and then wonder why they have 10 FPS. In your case I would go “if it works, it’s ok for now” or you can try timer (set timer by event) node outside of event tick and with every time speed change invalidate timer and calculate new remaining time for timer.
Sure no problem, so the thing is timer is timer so once it’s set it will just provide tick when it’s time either single or repeated but you’ve mentioned that you want to modify that duration when you change the speed of your game, unfortunately you can’t change speed of the timer countdown (or at least not to my knowledge) but you can invalidate it (stop it), calculate new time and start it again.
Sorry I’ve missed and also forgot about this. It will be probably the best approach since you don’t need any variables or additional logic.
You are right, you cannot change the time values inside the timeline but you can adjust play rate of the timeline which eventually will result in change of duration in the timeline. So 4s on 0.5 speed will result in 8 second countdown and so on. And the best part is you can change play rate at any time.