playMaker

Author Topic: How to send a event from script to fsm[SOLVED]  (Read 632 times)

Grezod

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
How to send a event from script to fsm[SOLVED]
« on: April 03, 2016, 04:21:36 AM »
i need use script to start my fsm function

but i don't know what code i can use to do this

can some one answer me  thanks a lot!
« Last Edit: April 03, 2016, 11:16:21 PM by jeanfabre »

Zeldag

  • Full Member
  • ***
  • Posts: 192
    • View Profile
Re: How to send a event from script to fsm
« Reply #1 on: April 03, 2016, 04:50:39 AM »
A simple way that I know, as a non coder, is:

Make a public bool in the script and turn it on in the script every time you want the fsm to run.

In the first state of the fsm, drag the script from the game object's inspector to the action list of the fsm and choose 'get property'. In the 'get property' action that should appear, chose to store the public bool from the script into a local bool in the fsm (do this every frame).

Then add a bool test (click 'every frame') and send to the next state if the bool is true.

In all subsequent events add the same actions but in the bool test action send back to the initial state if the bool is not true.

It is certainly not the most elegant way of doing it, but should work until a coder comes along and gives you the real solution...

Good luck with it!

Grezod

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: How to send a event from script to fsm
« Reply #2 on: April 03, 2016, 06:12:25 AM »
thank you Zeldag!

i'll try it

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: How to send a event from script to fsm
« Reply #3 on: April 03, 2016, 06:14:40 AM »
There's a code example on the wiki here

https://hutonggames.fogbugz.com/default.asp?W329