Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Poltor on November 24, 2017, 02:32:14 PM

Title: how to track a button click [SOLVED]
Post by: Poltor on November 24, 2017, 02:32:14 PM
Hello,
Tell me please how using the Playmaker you can track the click of a button in the scene?
In my scene there are 4 buttons Buy which are responsible for intra-game purchases, so I tried to check the press through the Get property and Bool Test, but unfortunately the Playmaker gave me an error from exceeding the number of cycles.
I tried through input, but in it I could not add my buttons from the game scene, it can use only those that are indicated in the unity - input manager.
I need to track 4 buttons at the same time, but I can figure out how to do it.
Title: Re: how to track a button click
Post by: Arnoob on November 24, 2017, 02:42:00 PM
Hello,

Have you tried to add a "tampon" state containing a "next frame event" action in order to avoid exceeding the number of cycles? Was "get property and bool test" returning the good value even though it crashed the FSM?
Title: Re: how to track a button click
Post by: Poltor on November 24, 2017, 03:32:38 PM
Hello,

Have you tried to add a "tampon" state containing a "next frame event" action in order to avoid exceeding the number of cycles? Was "get property and bool test" returning the good value even though it crashed the FSM?
Yes, it returned the good value that was pressed in the scene. But then the hang and error about exceeding the cycles.
No, I did not try to add "tampon" state containing a "next frame event" because I do not know what it is :).
Title: Re: how to track a button click
Post by: djaydino on November 24, 2017, 03:37:35 PM
HI,
Are these Ui buttons?

if so you can use Onclick()

also you should avoid using get/set properties, it is mend for 3th party components that don't have actions to support.

check out the tutorial page (http://www.hutonggames.com/tutorials_game_design_with_playmaker.php) and especially the User Tutorials Index (https://hutonggames.fogbugz.com/default.asp?W548) to get familiar with playmaker

(https://i.imgur.com/wU2Nfny.gif)
Title: Re: how to track a button click
Post by: Arnoob on November 24, 2017, 03:55:26 PM
Yes, it returned the good value that was pressed in the scene. But then the hang and error about exceeding the cycles.
No, I did not try to add "tampon" state containing a "next frame event" because I do not know what it is :).

What happens here is that your fsm is trying to make an infinite amount of actions during a single frame.
I guess that your FSM is making a loop, just take a look at it. It must be doing something like "check bool" in a state, and send an event to an other state when the bool is true. Then it gets back to the check bool state, and as the bool is still true for this frame sends the event once again. As you aren't telling it when to take a breack (wait for the next frame before checking again if the bool i strue), it is trying to check the bool endlessly, holding the release of the current frame.
Find the "next frame event" (or "wait" can also do the trick) and put it on the state that is entered when the bool is true. This way as soon as it enters this state, it will stop the looping for the current frame.

I hope that I was clear enough XD. Getting into it was a bit of a pain for me too, don't worry it's normal ;-)
Title: Re: how to track a button click
Post by: Poltor on November 24, 2017, 04:03:32 PM
HI,
Are these Ui buttons?

if so you can use Onclick()

also you should avoid using get/set properties, it is mend for 3th party components that don't have actions to support.

check out the tutorial page (http://www.hutonggames.com/tutorials_game_design_with_playmaker.php) and especially the User Tutorials Index (https://hutonggames.fogbugz.com/default.asp?W548) to get familiar with playmaker
Hi,
thanks, I tried this method, it works, but I have 4 different buttons, so when I hang on each FSM they are processed only inside their Playmakers.

Here in the picture is shown by the red arrow State in which I try to check the click on one of the 4 buttons.
https://imgur.com/a/vhbm6
Title: Re: how to track a button click
Post by: djaydino on November 24, 2017, 05:13:47 PM
Hi.
You can redirect all 4 there
Just set the transition name for each button.

So on button 1 in onclick() set the name "Button_1_Pressed"
in button 2 set "Button_2_Pressed" and so on.

all buttons pointing to the same gameobject/fsm.
Title: Re: how to track a button click
Post by: Poltor on November 24, 2017, 05:39:12 PM
Hi.
You can redirect all 4 there
Just set the transition name for each button.

So on button 1 in onclick() set the name "Button_1_Pressed"
in button 2 set "Button_2_Pressed" and so on.

all buttons pointing to the same gameobject/fsm.

Thank you, and you do not have one more wonderful gif? :)
And then I do not understand how to do it a bit, because I tried about the same and the transition did not work basically FSM.

UPD: Thanks, all figured out what you had in mind.
Title: Re: how to track a button click
Post by: djaydino on November 25, 2017, 05:32:05 PM
Hi,
Happy to help.