Player pawn time dilation vs global time dilation

Howdy brain trust,

Happy NY if you are reading this in a couple of hours!

Anyway - so I am trying to implement an “increase / decrease game speed” mechanic in my game - where the entire game EXCEPT THE PLAYER PAWN changes speed by an arbitrary increment (0.25 currently). I am doing this:

Which works great until you hit 0.0 on the global time dilation. Now I do realise this is a divide by zero issue…

My question is; Given that the Custom Time Dilation is a MULTIPLE of the Global Time Dilation value - how do you get it to be 1.0 when the rest of the game is effectively paused?

Woulda been smarter if the devs just made the local and global absolute rather than relative…

UPDATE: This does work but it feels like a bit of a hacky work around:

Hey there,

As far as I understand, setting Global Dilation to 0 stops any code from being executed (or it’s that slow) there is no way to recover from it.

So you would need to establish a value you can recover from later on (eg. 0.01). I believe you’re using 0.0001 which might be a bit too low, but I will leave it to you to fine tune the values. :wink:

I did a little bit of testing (not much), and for slowing global time and keeping player at “1” speed you could do something like this. I believe the below would work for speeding up past “1” global dilation too.

This should always keep your player at original (1) speeds.

Perhaps you will find this helpful.

Functionally the same as what i ended up doing. Thanks though!

1 Like

It’s not that it’s unrecoverable - it doesn’t “stop all code from running” it simply sets all event ticks to zero - so they effectively stop. you can still increase it back from zero (which is how i had it working originally) so clearly stuff is still working in the background.

the main issue here is because the “custom time dilation” is a multiple of the global one - if the global one is ZERO - there’s nothing you can multiply zero by to get anything other than zero…

so it must be SOMETHING - the 0.0001 works, anything lower and it causes issues - i tried a bunch of diff values and they did not set the custom dilation correctly

it would be good if this didn’t need to be relative and could be absolute - i guess i understand how this has happened though, in terms of the underlying code - but still it means you can’t actually “pause” everything and still let some stuff (eg. player controller) do it’s thing - which reduces flexibility in what you want to do…

I guess i could write my own custom mechanism and have every event tick in the game use it - set everything as a custom dilation and never touch the global one - but that feels flakey and painful

1 Like

I wonder…like the “speed up / down” thing could easily be enacted by a “deltaseconds x multiplication factor (speed of game)” - i could just hook this in as a multiplier of the delta seconds on every event tick…and tbf i am not using THAT many event ticks yet…

think i might go with this actually - rather than using the global / custom dilation method:

In a blueprint function library:

And then in my player controller:

Means i can selectively work out which bits i want to be slowed / sped up and isn’t messing about with weird multiples

is this a crazy way to do it?

quick update - dunno what it is but this approach causes BIG performance issues over time - don’t do it this way - use the standard gobal / custom time dilation method

have settled on this:

Also here there’s no point in the multiply - coz custom time dilation is ALWAYS 1 in your code