Hello All -
I have an Actor that I spawn that displays a message to the user, plays a sound and then waits for either a timer to expire or for the user to press a button.
I am using “Set Game Paused” to pause the game in the background? And for the actor I am spawning, I have set the “Enable Tick when Game Paused” to True. (I am setting is manually when spawned but it is also set on the BP details panel itself)
However, the problem is that the code inside the spawned actor stops as soon as it executes the “pause game” unless I have active code attached to the event tick.
I created a float variable and am just setting it to delta seconds and when I did this, the code inside the actor keeps executing as expected. I ended up adding a .1 delay to cut down on the cycles, but this still seems like a waste of processing/cycle time.
Is there a better way to do this?
This is the code spawning the actor inside my game:
This is a snippet of code from the actor being spawned:
hey @DurrinTreyvan how are you?
There are two different ways to do this.
You can handle all that in your actor instead of when spawning it. You should set the actor’s “Tick Even when Paused” in true on its details, and then you can do something like this:
In this case, the variable “TimeRemaining” is a float that you should set with the time you want.
With this approach, you don’t need to worry about handling all of this when you spawn the actor, as the actor will manage itself.
You don’t need to worry about the tick if you will destroy the actor after that time. As it won’t be ticking after being detroyed.
But if you don’t want to destroy the actor, is REALLY important to use the node “Set Actor Tick Enabled” and set it false after executing your tick logic so the Event Tick stops running for that actor.
Let me know if you need more help!
Thanks @BRGJuanCruzMK! I think your solution is a bit more elegant and makes me feel like i’m not wasting cycles and can clean up the implementation a bit.
Still don’t understand why I need something attached to the event tick as I would expect it to execute all of the code inside the actor, but my assumption is it purely executes what’s attached to the event tick which I could seeing also being a useful way to implement/manage.
Unreal Engine definitely presents some interesting challenges when trying to implement code that is meant to be more serial in nature.
Thanks again - you’ve given me a good solution but also helped me better understand how this setting is implemented.