playMaker

Author Topic: How to enable/disable an action from another FSM?  (Read 4437 times)

Adam Z

  • Full Member
  • ***
  • Posts: 207
How to enable/disable an action from another FSM?
« on: March 16, 2016, 01:47:32 PM »
I have a Movement FSM and on my Movement State within I have a Mouse Look Action.  On another FSM I have a button with two States. Within one of these States I'd like to enable/disable the Mouse Look Action. is it possible?

Thanks.

Unisonkid

  • Playmaker Newbie
  • *
  • Posts: 33
Re: How to enable/disable an action from another FSM?
« Reply #1 on: March 16, 2016, 01:54:54 PM »
I am tryin to do the exact same thing, please let me know if you find a solution thanks. :D

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Re: How to enable/disable an action from another FSM?
« Reply #2 on: March 16, 2016, 03:42:07 PM »
You'll need to get the velocity of your character, store it as a variable and check if it's reached 0 in the walk and run state. If the variable = 0 go back to idle.
 
You create a variable here:
https://hutonggames.fogbugz.com/default.asp?W50
 
Get Velocity here:
https://hutonggames.fogbugz.com/default.asp?W320

You'll probably have to convert a Vector2 to a Float and then monitor that float every frame until it is 0, using Float Compare:
https://hutonggames.fogbugz.com/default.asp?W80

This type of stuff isn't super easy if you're just starting out but if you watch all of the 13 tutorial videos, you'll be in a much better position to get things working how you want:
http://www.hutonggames.com/tutorials_game_design_with_playmaker.php

Adam Z

  • Full Member
  • ***
  • Posts: 207
Re: How to enable/disable an action from another FSM?
« Reply #3 on: March 16, 2016, 04:04:34 PM »
You'll need to get the velocity of your character, store it as a variable and check if it's reached 0 in the walk and run state. If the variable = 0 go back to idle.
 
You create a variable here:
https://hutonggames.fogbugz.com/default.asp?W50
 
Get Velocity here:
https://hutonggames.fogbugz.com/default.asp?W320

You'll probably have to convert a Vector2 to a Float and then monitor that float every frame until it is 0, using Float Compare:
https://hutonggames.fogbugz.com/default.asp?W80

This type of stuff isn't super easy if you're just starting out but if you watch all of the 13 tutorial videos, you'll be in a much better position to get things working how you want:
http://www.hutonggames.com/tutorials_game_design_with_playmaker.php

Thanks for this. But I'm looking for something a bit simpler since I dont want to have two states in my movement fsm. 

My movement state has a mouse look which rotates my character.  My 2nd fsm has a two states that switches when a button is pressed. So when I press a button, I'd like to de-activate the mouse look on my Movement FSM, and when un-press the button I'd like it to re-activate the mouse look.

I thought there might have been an action which could toggle on/off another action on an FSM.

Unisonkid

  • Playmaker Newbie
  • *
  • Posts: 33
Re: How to enable/disable an action from another FSM?
« Reply #4 on: March 16, 2016, 05:03:33 PM »
Create a Global Bool and then use set bool in the state and set the global as the stored bool. from there you can use bool test

Adam Z

  • Full Member
  • ***
  • Posts: 207
Re: How to enable/disable an action from another FSM?
« Reply #5 on: March 16, 2016, 05:10:26 PM »
Create a Global Bool and then use set bool in the state and set the global as the stored bool. from there you can use bool test

The problem is that I dont want to transition to another State, I just want to be able to turn the Action and and off from another FSM.

Zeldag

  • Full Member
  • ***
  • Posts: 198
Re: How to enable/disable an action from another FSM?
« Reply #6 on: March 16, 2016, 07:40:25 PM »
Is there a specific reason you want to stay in that state? I am no expert but I think the whole idea of a state machine is that you must change state to achieve a change of behavior, apart from some exceptions which I cant think of now.


If you want to keep all the behavior that is in that state, but change that one action. Copy and paste that state and then make the changes to the action(such as delete it) in the duplicate state. Transition between the states whenever you need the change to be implemented.

You can even do the sending of the transition from another fsm by using global events and 'send event' action.

I think this should really work fine in most circumstances, but if you explain why it would not work in your case, maybe it would help in finding a work-around your issue (or at least teach me something about what circumstances would require this).

(Also I know nothing about writing code, but maybe a script could do such a thing- or a new action- if one does not exist somewhere out there already...)

Also I am not at my computer to try this, but you really got me wondering what happens if you use 'set property' on an FSM...

Hope that helps, good luck with it!

(Edit: also I think this post makes me a' junior playmaker'. Yippeee me!- sorry to steal any limelight)
« Last Edit: March 16, 2016, 08:26:07 PM by Zeldag »

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Re: How to enable/disable an action from another FSM?
« Reply #7 on: March 17, 2016, 05:14:13 AM »
You'll need to get the velocity of your character, store it as a variable and check if it's reached 0 in the walk and run state. If the variable = 0 go back to idle.
 
You create a variable here:
https://hutonggames.fogbugz.com/default.asp?W50
 
Get Velocity here:
https://hutonggames.fogbugz.com/default.asp?W320

You'll probably have to convert a Vector2 to a Float and then monitor that float every frame until it is 0, using Float Compare:
https://hutonggames.fogbugz.com/default.asp?W80

This type of stuff isn't super easy if you're just starting out but if you watch all of the 13 tutorial videos, you'll be in a much better position to get things working how you want:
http://www.hutonggames.com/tutorials_game_design_with_playmaker.php

Thanks for this. But I'm looking for something a bit simpler since I dont want to have two states in my movement fsm. 

My movement state has a mouse look which rotates my character.  My 2nd fsm has a two states that switches when a button is pressed. So when I press a button, I'd like to de-activate the mouse look on my Movement FSM, and when un-press the button I'd like it to re-activate the mouse look.

I thought there might have been an action which could toggle on/off another action on an FSM.

Oops. Soz, posted to the wrong thread  ;D

Adam Z

  • Full Member
  • ***
  • Posts: 207
Re: How to enable/disable an action from another FSM?
« Reply #8 on: March 17, 2016, 11:06:19 AM »
Is there a specific reason you want to stay in that state? I am no expert but I think the whole idea of a state machine is that you must change state to achieve a change of behavior, apart from some exceptions which I cant think of now.


If you want to keep all the behavior that is in that state, but change that one action. Copy and paste that state and then make the changes to the action(such as delete it) in the duplicate state. Transition between the states whenever you need the change to be implemented.

You can even do the sending of the transition from another fsm by using global events and 'send event' action.

I think this should really work fine in most circumstances, but if you explain why it would not work in your case, maybe it would help in finding a work-around your issue (or at least teach me something about what circumstances would require this).

(Also I know nothing about writing code, but maybe a script could do such a thing- or a new action- if one does not exist somewhere out there already...)

Also I am not at my computer to try this, but you really got me wondering what happens if you use 'set property' on an FSM...

Hope that helps, good luck with it!

(Edit: also I think this post makes me a' junior playmaker'. Yippeee me!- sorry to steal any limelight)

The reason is if I set up two States: Idle and Movement, and toggle between them based on Float Compares, I get an error: "Loop Count exceed maximum: 1000 Default is 1000. Override in Fsm Inspector."

On the Idle state I have 2 Float Compares for Input X, and 2 Float Compares for Input Z (forward/backward and strafe left/right). If any of those exceeds 0, then play a state to transition to Movement.

I have the same on Movement, so if any of my floats equal 0, then go back to the Idle state.

I think I'll explore 4ppleseed's suggestions and use velocity instead of getting the floats of the inputs.

Adam Z

  • Full Member
  • ***
  • Posts: 207
Re: How to enable/disable an action from another FSM?
« Reply #9 on: March 17, 2016, 11:12:40 AM »
You'll need to get the velocity of your character, store it as a variable and check if it's reached 0 in the walk and run state. If the variable = 0 go back to idle.
 
You create a variable here:
https://hutonggames.fogbugz.com/default.asp?W50
 
Get Velocity here:
https://hutonggames.fogbugz.com/default.asp?W320

You'll probably have to convert a Vector2 to a Float and then monitor that float every frame until it is 0, using Float Compare:
https://hutonggames.fogbugz.com/default.asp?W80

This type of stuff isn't super easy if you're just starting out but if you watch all of the 13 tutorial videos, you'll be in a much better position to get things working how you want:
http://www.hutonggames.com/tutorials_game_design_with_playmaker.php

Thanks for this. But I'm looking for something a bit simpler since I dont want to have two states in my movement fsm. 

My movement state has a mouse look which rotates my character.  My 2nd fsm has a two states that switches when a button is pressed. So when I press a button, I'd like to de-activate the mouse look on my Movement FSM, and when un-press the button I'd like it to re-activate the mouse look.

I thought there might have been an action which could toggle on/off another action on an FSM.

Oops. Soz, posted to the wrong thread  ;D

That's ok. Your tip actually helped and I got my issue resolved, so thanks!