playMaker

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

Grezod

  • Playmaker Newbie
  • *
  • Posts: 5
How to send a event from script to fsm[SOLVED]
« 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!
« Last Edit: April 04, 2016, 02:16:21 AM by jeanfabre »

Zeldag

  • Full Member
  • ***
  • Posts: 198
Re: How to send a event from script to fsm
« Reply #1 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!

Grezod

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

i'll try it

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: How to send a event from script to fsm
« Reply #3 on: April 03, 2016, 09:14:40 AM »
There's a code example on the wiki here

https://hutonggames.fogbugz.com/default.asp?W329
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D