playMaker

Author Topic: Disable/Enable actions in state during Runtime?  (Read 5626 times)

Unisonkid

  • Playmaker Newbie
  • *
  • Posts: 33
Disable/Enable actions in state during Runtime?
« on: March 10, 2016, 10:17:00 AM »
Can you disable/enable actions in a state during Runtime so that if the state is returned to for any reason it will have that action turned on or off? I want to be able to test things, so I turn off actions that I don't need within a state, but sometimes I would like to enable them and so far I have to manually click to enable the action during playmode. can this be accomplished thru a playmaker action? Thank you in advance.

Unisonkid

  • Playmaker Newbie
  • *
  • Posts: 33
Re: Disable/Enable actions in state during Runtime?
« Reply #1 on: March 16, 2016, 11:39:28 AM »
Can anybody help with this or does this not have a solution?

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Re: Disable/Enable actions in state during Runtime?
« Reply #2 on: March 16, 2016, 12:56:18 PM »
So you only want the action to be off if it's the second time the logic has come to it?

Unisonkid

  • Playmaker Newbie
  • *
  • Posts: 33
Re: Disable/Enable actions in state during Runtime?
« Reply #3 on: March 16, 2016, 01:51:33 PM »
ok so lets say I have a fsm that has a wait action for 5 secs then finished event to another State right? ok so in the 2nd state it has a rotate action running every frame right? I want to be able to disable the rotate action in State 2. Not the whole FSM but just that rotate action.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Disable/Enable actions in state during Runtime?
« Reply #4 on: March 16, 2016, 02:06:21 PM »
There is currently no way to disable/enable individual actions at runtime. Generally speaking a state should do one specific thing. Enabling/disabling actions could become quite confusing when debugging the FSM.

You could either use a second state for the different behaviour. Or use variables to change the behaviour of a state. In your example you could use a variable for the rotation amount and set it to 0,0,0.

I've considered adding the option to enable/disable actions with a bool variable but am worried that it will make FSMs less clear. Like a flowchart it's generally better to break the behaviour down into simple explicit blocks. But I'm interested in feedback on the idea...

 

Unisonkid

  • Playmaker Newbie
  • *
  • Posts: 33
Re: Disable/Enable actions in state during Runtime?
« Reply #5 on: March 16, 2016, 02:32:38 PM »
ok awesome thank you for the feedback its sad to know there is no way currently to do that as I have some FSM that just require for that action to run for as long as I have it set and then be disabled when I don't need it but there are still actions within that state that I still need to be running. But hopefully in there future there might be something created for that. Also is there any way an action can be create to enable/disable Multiple FSMs? Someone created (sorry for not having the credited creator for this example ;)) a Activate Multiple GameObjects, would it be possible to mimic that action but have it be applied to multiple FSMs?

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Re: Disable/Enable actions in state during Runtime?
« Reply #6 on: March 16, 2016, 03:36:21 PM »
ok so lets say I have a fsm that has a wait action for 5 secs then finished event to another State right? ok so in the 2nd state it has a rotate action running every frame right? I want to be able to disable the rotate action in State 2. Not the whole FSM but just that rotate action.

Why not just create a third state that stops the rotate action and move to that when needed?

dudebxl

  • Hero Member
  • *****
  • Posts: 602
Re: Disable/Enable actions in state during Runtime?
« Reply #7 on: March 16, 2016, 04:05:57 PM »
@Alex

Please don't add this feature.. i am sure I will use this feature and then forget that i disabled something.. and spend more time debugging..  :(

 :)

Unisonkid

  • Playmaker Newbie
  • *
  • Posts: 33
Re: Disable/Enable actions in state during Runtime?
« Reply #8 on: March 16, 2016, 04:48:38 PM »
@Alex lol add the feature and just don't use it  ;). And as far as the third state solution the problem is that I have additional actions running in that state and if I leave the state I lose those Actions. so I would like to be able to disable a particular action within a state rather than creating additional FSM to disable the one I have or leaving the state and returning.
 

dudebxl

  • Hero Member
  • *****
  • Posts: 602
Re: Disable/Enable actions in state during Runtime?
« Reply #9 on: March 16, 2016, 05:50:13 PM »
@ Unisonkid

Why don't you use bools or int switch and have different path based on your needs?

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Disable/Enable actions in state during Runtime?
« Reply #10 on: March 16, 2016, 06:14:19 PM »
@Unisonkid

A couple of things to consider:

It is often better to have multiple simple FSMs than one complex FSM. If a State is doing X and also doing Y only if Z, it's a good indication that Y should be it's own State, maybe in a separate FSM just managing that state. For example maybe you have a Rotation FSM that just manages rotation.

Or, another option, you can run through multiple states in a single update. So you can do X in one state, test a condition, then do Y in another state and loop back to the X state with a Next Frame Event. That way you can loop through a whole set of decisions and states in a single update. Think of a flow chart where each action and decision is broken down into a single block.

Both of these strategies keep the logic explicit in the graph, instead of hiding an important behaviour switch in the action stack. Does that help any? I'll try to document these strategies on the wiki to make them clearer.

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Re: Disable/Enable actions in state during Runtime?
« Reply #11 on: March 17, 2016, 05:16:26 AM »
@Alex lol add the feature and just don't use it  ;). And as far as the third state solution the problem is that I have additional actions running in that state and if I leave the state I lose those Actions. so I would like to be able to disable a particular action within a state rather than creating additional FSM to disable the one I have or leaving the state and returning.

Use multiple FSMs. One that just controls the rotate, that you can turn on and off and another FSM on the same object that does everything else. You can Send Event between the two to make them talk to each other.