playMaker

Author Topic: How to make an action Finish() but still run OnUpdate()?  (Read 2555 times)

GarthSmith

  • Playmaker Newbie
  • *
  • Posts: 31
  • Games. Math. Code.
    • Garth Smith's Website
How to make an action Finish() but still run OnUpdate()?
« on: December 03, 2014, 04:23:10 PM »
Hello!

I have an action that I want to run every frame while other actions have not yet finished.

If I tell this action to Finish(), it ends right away and stops running even though other actions are still running in that state.

If I tell this action never to Finish(), the FSM does not transition to a new state because all other actions have not Finish()ed yet.

Is there a way I can Finish() this action yet still have OnUpdate() running as long as I'm in this state?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: How to make an action Finish() but still run OnUpdate()?
« Reply #1 on: December 03, 2014, 08:23:44 PM »
Not really. What would the use case be for this? It's basically an inactive action still doing somehting right? You could probably just segment your action into methods that you only fire on certain conditions, like if (!isFinished), considered in the OnUpdate loop.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How to make an action Finish() but still run OnUpdate()?
« Reply #2 on: December 03, 2014, 09:17:45 PM »
maybe you can use a 2nd fsm that includes those Actions that you want to run every frame and trigger that event from your 1st fsm using "send event" Action.

here is a tutorial video about that , you can skip to 14:50 if you want.

you can also right-click on an event and add a global transition so you can call that event any time you want here is a sample skip to 26:20

GarthSmith

  • Playmaker Newbie
  • *
  • Posts: 31
  • Games. Math. Code.
    • Garth Smith's Website
Re: How to make an action Finish() but still run OnUpdate()?
« Reply #3 on: December 05, 2014, 06:03:18 PM »
The use case:
We use PlayMaker to control what our characters do. We originally would add gravity to a character's velocity in most of their custom actions.

Instead of making almost all our actions run the ApplyGravity() function, we were attempting to make a separated "ApplyGravityEveryFrame" action that ran as long as we were in the state.

Our workaround:
We just made our other custom actions able to optionally raise an event when done. This forces a transition to occur without waiting for other actions to Finish().

Or sometimes we may just call ApplyGravity() from within the other custom actions directly and not use the "ApplyGravityEveryFrame" action for that state,

Final thoughts
This is the only time I've ever wanted an action to run OnUpdate() even though it had already Finished(). Our workarounds work well, so I don't suggest changing PlayMaker for our one case!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How to make an action Finish() but still run OnUpdate()?
« Reply #4 on: December 05, 2014, 08:35:58 PM »
i think using a different Fsm would be beter.

like this :




and use Send event to apply Gravity and send event again to stop gravity.