playMaker

Author Topic: Using button to direct communicate to FSM event??  (Read 2562 times)

keitaro3660

  • Playmaker Newbie
  • *
  • Posts: 16
Using button to direct communicate to FSM event??
« on: December 27, 2014, 11:18:16 PM »
hi there, i already try to google search this topic, but i can't found it...

so please help me,
i use Button asset for my game..

is there a way for a BUTTON that use this type :
-Send Message
-Send Message Upward
-Broadcast Message

to simply just send that message directly to Game Object FSM/FSM Event without using script?
i already tried that playmaker global event, and then Broadcast Event for the button. but nothing work..

what should i do??

wheretheidivides

  • Sr. Member
  • ****
  • Posts: 496
Re: Using button to direct communicate to FSM event??
« Reply #1 on: December 28, 2014, 02:05:50 AM »
In state 1, wait for a button click.  When clicked, go to state 2 which has the event call.
--------------------------------------------------
Create a button (create, ui, button). 
get action 'uiguibuttonevent'
right click on button (not canvas) and use 'action browser' to put in 'uguibuttonevent'.
Create event 'gotostate2'
on 'ugui button event' under 'send event', put in 'gotostate2'
right click on state, add transition 'gotostate2'
Create state 2 and draw line from state 1 to state 2
in state 2, put in 'send event' action.

'send event' (event taget-game object fsm), game object(specify game object), under that drag game object, FSM name ('FSM' if you have not changed its name) and finally send event (this is the event to trigger.  in the game object, one of the transition events will appear here.  You must have it marked as global if its not on this game object)

So use the action button click on state 1.  Add an event/transition and call it 'gotostate2'.  So when the button is clicked, it will goto state 2 using that event (gotostate2).

On state 2, add a action 'event'.  This will call a FSM and transition to trigger.