playMaker

Author Topic: Detect FsmName in script (javascript)  (Read 1903 times)

vincent_soo

  • Playmaker Newbie
  • *
  • Posts: 1
Detect FsmName in script (javascript)
« on: September 06, 2012, 03:34:49 AM »
Hi Guys,

I have a gameobject which have 3 FSM in it and I name it to FSM JUMP, FSM SLIDE, FSM CHARGE.
Each of it have a boolean, FSMtouchJump, FSMtouchCharge, FSMtouchSlide.

FSM JUMP is the 1st FSM I created, when I trigger each of this FSM my script will detect weather they are true or false

My problem is my script only able to detect the 1st FSM I created which is FSM JUMP.

Here the script I use for the FSM detect

Code: [Select]
if(GUICharFSM.FsmVariables.GetFsmBool("FSMtouchJump").Value==true){
      //Success Detect

}
if(GUICharFSM.FsmVariables.GetFsmBool("FSMtouchCharge").Value==true){
       //Nothing happen when trigger
}
if(GUICharFSM.FsmVariables.GetFsmBool("FSMtouchSlide").Value==true){
       //Nothing happen when trigger
}

So I doubt it can't detect because of the way I written is wrong
Is there something like
Code: [Select]
GUICharFSM("FSM SLIDE").FsmVariables.GetFsmBool("FSMtouchSlide").Value==trueSomething like that? So my script can detect it is true or false from the other 2 FSM.

Sorry my programming is not good, I have try many way and try to write it but it just not working  :-[
Anyone can help or advice?

Thank you

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Detect FsmName in script (javascript)
« Reply #1 on: September 06, 2012, 03:54:07 AM »
Hi,

 you need the proper reference of the fsm you want to get its variable from.

All your checks are suing the same "GUICharFSM", so that can't not work, you need three variables, each one referencing the fsm component itself, NOT the gameObject.

to do so, you need to drag the component top bar, then you will reference that component directly, else if you drag the gameObject, it will simply find the first fsm component attached and point to this one only.

 The other thing you can do is use getComponents() and iterate through them and check their fsm name, that's another way to get to a particular fsm directly,

bye,

 Jean