playMaker

Author Topic: how to track a button click [SOLVED]  (Read 4036 times)

Poltor

  • Playmaker Newbie
  • *
  • Posts: 26
how to track a button click [SOLVED]
« 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.
« Last Edit: November 25, 2017, 05:32:24 PM by djaydino »

Arnoob

  • Junior Playmaker
  • **
  • Posts: 63
Re: how to track a button click
« Reply #1 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?

Poltor

  • Playmaker Newbie
  • *
  • Posts: 26
Re: how to track a button click
« Reply #2 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 :).

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: how to track a button click
« Reply #3 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 and especially the User Tutorials Index to get familiar with playmaker


Arnoob

  • Junior Playmaker
  • **
  • Posts: 63
Re: how to track a button click
« Reply #4 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 ;-)

Poltor

  • Playmaker Newbie
  • *
  • Posts: 26
Re: how to track a button click
« Reply #5 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 and especially the User Tutorials Index 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
« Last Edit: November 24, 2017, 05:06:47 PM by djaydino »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: how to track a button click
« Reply #6 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.

Poltor

  • Playmaker Newbie
  • *
  • Posts: 26
Re: how to track a button click
« Reply #7 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.
« Last Edit: November 25, 2017, 04:13:45 AM by Poltor »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: how to track a button click
« Reply #8 on: November 25, 2017, 05:32:05 PM »
Hi,
Happy to help.