Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Karin on August 05, 2020, 05:57:18 AM
-
Hello
I've been trying to figure out the best possible way for an FSM to repeat a function loop upon creating a projectile. The issue is on get key down and key up, they don't seem to read if the new event tries to detect button presses consistently.
I would be interested to know how others would approach this.
-
Use a "key down", or equivalent, in the first state, use a "wait" action in the next state. Set the wait timer to something small like 0.1
Have the states be connected together, and hey presto! A simple repeating loop as long as the button is pressed.
-
Use a "key down", or equivalent, in the first state, use a "wait" action in the next state. Set the wait timer to something small like 0.1
Have the states be connected together, and hey presto! A simple repeating loop as long as the button is pressed.
As I mentioned in my post I did exactly that. It does not loop. I tested it with a debug log feed just to be sure of it.
-
Hi.
You could separate the fsm key part to enable disable the projectile shooting.
(Best solution but might take a little more time to set up)
FSM 1 :
State 1
Get Key Down (transition to state 2)
Send Event (By Name) send 'Disable' Event
State 2
Get Key Up (transition to state 1)
Send Event (By Name) send 'Enable' Event
Fsm 2 :
Have a empty state and place a global event (Disable)
Then have a Global Event Connected to your projectile States.
Or you could use a 'Get Key' and get the bool Status, then do a bool test on that value.
(fastest solution)
-
Hi.
You could separate the fsm key part to enable disable the projectile shooting.
(Best solution but might take a little more time to set up)
FSM 1 :
State 1
Get Key Down (transition to state 2)
Send Event (By Name) send 'Disable' Event
State 2
Get Key Up (transition to state 1)
Send Event (By Name) send 'Enable' Event
Fsm 2 :
Have a empty state and place a global event (Disable)
Then have a Global Event Connected to your projectile States.
Or you could use a 'Get Key' and get the bool Status, then do a bool test on that value.
(fastest solution)
That's a very interesting approach, thanks I'll get back to you on the result.
-
Hi.
Key Down will be registered once by a action.
If its still holding down when looping back, it won't see this as a pressing down. as key has not been released since.
And in scripting it works the same ways, as in many other cases you would not want to loop, until pressed again.
-
Hi.
Key Down will be registered once by a action.
If its still holding down when looping back, it won't see this as a pressing down. as key has not been released since.
And in scripting it works the same ways, as in many other cases you would not want to loop, until pressed again.
My thoughts exactly, because it's not the same as Key hold. I don't think Playmaker has this function, is it possible to make this as a custom action?
-
Hi.
'Get key' + 'Bool Test' is doing this.
Make sure to Enable Every Frame.
-
Are we talking every frame for both Get key and Bool test?
Regardless of the combination I get 1000 reach crash, i must be doing something wrong. I may have to show pics of what it is I'm trying to achieve.
For a moment i was under the impression key was another version of key down. I had no idea it had every frame.
-
Hi.
Yes as it should get the value every frame and also check the result every frame.
Else it will only Get/Test once.
-
This requires a third state, because it's going WAY too fast!
This allows the conditions you mentioned to breath, because it's going at a speed that the FSM can't deal with.
Thanks once again this very helpful. :D
Out of curiosity does FSM state switch, work on a global status?
-
Hi.
Set a wait in between the loop to have a delay for this case as you probably want a certain time between each shot.
In other cases there is also a 'Next Frame Event'
Out of curiosity does FSM state switch, work on a global status?
To check the state on another, yes.
The send event on the action is local.