playMaker

Author Topic: Drain when Paused  (Read 1946 times)

kiramarshiku

  • Playmaker Newbie
  • *
  • Posts: 10
Drain when Paused
« 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?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Drain when Paused
« Reply #1 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

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Drain when Paused
« Reply #2 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.

kiramarshiku

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Drain when Paused
« Reply #3 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.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Drain when Paused
« Reply #4 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.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Drain when Paused
« Reply #5 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:



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
« Last Edit: September 21, 2017, 03:01:38 AM by jeanfabre »