I’m setting the time dilation to 0 but I’m finding that my actor’s Tick() functions are still being called and being passed a small amount of time. For example, if I leave the time dilation at its default value of 1.0 then I find that my Tick() functions are being passed a value normally somewhere in the region of 0.01 - but if I set the dilation to 0.f then it’s being passed a value in the region of 0.0002.
What that means is that the simulation hasn’t stopped, it’s just much slower now. I’d expect the values to be 0.f when the time dilation is set to 0.f.
Incidentally, it doesn’t matter how I set the time dilation - I do this either by setting the AWorldSettings object directly (pointed to by the UWorld object) or by using UGameplayStatics::SetTimeDilation (which I suspect is doing the same thing anyway!).
I want the simulation to stop (I want the actor Tick functions to be passed a delta of 0.0 seconds) but still allowing the player to pan the camera around.
I would expect the time dilation value to directly affect the delta being passed into the Tick functions - which is true. I would expect the code to be something like:
…which then changes into the Pause game mode. I then need to ensure that the bShouldPerformFullTickWhenPaused member variable of the PlayerController object is set to true. That then allows me to “move” my camera around the world.
I tried many other options (such as those suggested by Luke, Fabrice and Alexander - thanks guys!) but this was the only way I found that worked.
When the game was paused I saw that APlayerController:ProcessPlayerInput() was being called and was updating my camera - but no changes were rendered until the game was unpaused (that seems to be a bug in UE4!). I tried using SetActorTickEnabled() on my camera object - but no dice.
Setting bPlayersOnly didn’t work either unfortunately.
Anyway, thank you everybody for your advice! I have it working now - and seemingly have found two bugs in UE4 because of it (the one mentioned before and another with regards with particles which I’ll post about separately).
The reason that Time Dilation does not completely stop tick is that it could lead to a lot of different problems with tick events causing errors. So as a measure to prevent the errors, Time Dilation can not be set to 0. What I recommend is get it as close as you can to 0, then switch to paused and use SetTickableWhenPaused to enable tick; I believe this is what Fabrice is mentioning was in UE3. I hope that this helps to clarify.
There’s a function you can oveeride that determines if an actor should still tick when the game is paused ( virtual bool IsTickableWhenPaused() ), but this seems like a bad idea, considering you might still want to be able to pause the game, whereas what you are describing sounds like a game mechanic.
I would recommend looking at bPlayersOnly. It is intended as a debug function (it also exists in UE3), but I believe it may well do exactly what you’re after.
What you want to do is stop ticking all gameplay actors except the player - there is a function in Actor to do this for you:
virtual void SetActorTickEnabled(bool bEnabled);
However, I believe the bPlayersOnly flag in World will also do this for you, and should be more convenient than iterating through every one of your actors:
GetWorld()->bPlayersOnly = true inside PlayerController.
Thanks for the suggestion! I’m going to try this and see what happens. I don’t (currently!) want to accept this answer because I really want Epic staff to reply and answer.
What you’re suggesting seems like it could work - but it also seems kludgey (which isn’t your fault!). If that ends up being the final answer then, well, I’ll live with it - but I’d love to know how this is meant to work with games that want Matrix style bullet-time effects (think about the simulation stopping and the camera spinning around the character before the simulation starts back up again).
I know this is a couple months old, but i stumbled on this post for a problem i’m having. I have my pause/unpause working, but i can’t get my camera to accept input during pause. My camera is a separate actor from my playercontroller and handles it’s own input. In its construction blueprint, i’m setting ‘TickableWhenPaused’ to true, but its processing any events i send only after i unpause.
Can you post this as a new question on the AnswerHub along with a link to this post? This is from our beta and is now archived so it is no longer tracked by any of our support staff.