Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: kiramarshiku on September 18, 2017, 03:39:03 PM

Title: Drain when Paused
Post by: kiramarshiku on September 18, 2017, 03:39:03 PM
I have some float variables that I want to constantly drain even when the application is paused or exited. Now I found a way to use actions so the age even goes up even when the game is paused and am planning to use GetSystemDateTime to calculate how much time has passed and add the time to the age when the app is opened again. I haven't found a way to drain float variables when the game is paused yet. Does anyone have an idea to help me out?
Title: Re: Drain when Paused
Post by: jeanfabre on September 19, 2017, 02:48:24 AM
Hi,

 If you affect the time scale when you pause, that would be the reason why. But first you need to explain how exactly you are getting the time.

 Bye,

 Jean
Title: Re: Drain when Paused
Post by: djaydino on September 19, 2017, 07:26:38 AM
Actions that have realtime check can be still used so if you would set a "wait" with realtime enabled to 1 sec  and then use add float -1 in the next state and loop back to the wait state n will drain 1 per second.
after add float you can set a compare if needed.
Title: Re: Drain when Paused
Post by: kiramarshiku on September 20, 2017, 02:55:12 PM
Hi,

 If you affect the time scale when you pause, that would be the reason why. But first you need to explain how exactly you are getting the time.

 Bye,

 Jean

With the float variables I'm not getting the time, I'm just using subtract float and setting it per second.
Title: Re: Drain when Paused
Post by: djaydino on September 20, 2017, 11:57:15 PM
Hi,
The 'per second' is using time
The problem is that this action does not have a 'realtime' option, so if you scale time to 0 it will will not continue.
If you would set scale time to 0.5 the float subtract would go half speed.
Title: Re: Drain when Paused
Post by: jeanfabre on September 21, 2017, 02:37:21 AM
Hi,

 yes, you need to actually get the unscaled delta time and do the substraction manually. I made it easy with an update of the action GetTimeInfoAdvanced where you can get the unscaledDeltaTime and do the substraction yourself:

(https://i.imgur.com/E0iDerG.gif)

however, this is not accouting for when your app goes into the background, if you want to drain a value based on true time, you will need to use timestamps and do the math of how much time elapsed since the begining of the game or else and drain the float accorgingly, then that will work always and in all situations.

check this for example: http://hutonggames.com/playmakerforum/index.php?topic=14323.msg66438#msg66438


 Bye,

 Jean