Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Grezod on April 03, 2016, 07:21:36 AM

Title: How to send a event from script to fsm[SOLVED]
Post by: Grezod on April 03, 2016, 07: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!
Title: Re: How to send a event from script to fsm
Post by: Zeldag on April 03, 2016, 07: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!
Title: Re: How to send a event from script to fsm
Post by: Grezod on April 03, 2016, 09:12:25 AM
thank you Zeldag!

i'll try it
Title: Re: How to send a event from script to fsm
Post by: Lane on April 03, 2016, 09:14:40 AM
There's a code example on the wiki here

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