playMaker

Author Topic: Reading FSM state from script  (Read 2428 times)

liero116

  • Playmaker Newbie
  • *
  • Posts: 21
Reading FSM state from script
« on: March 01, 2012, 12:00:26 PM »
I am looking for a way to read what state my character's FSM is in.  For example, I have a state named "jump_up".  I want to be able to script something along the lines of this (pseudo code):

Code: [Select]

if ( FSM.Event ( "jump_up" ) )
{
        dostuff.etc
}


How can I go about doing this?  Or rather, what is the actual way to do it?
« Last Edit: March 01, 2012, 12:36:11 PM by liero116 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Reasing FSM state from script
« Reply #1 on: March 01, 2012, 12:16:45 PM »
Hi,

 Two ways, two actions available for this:

Either you can send a message, or invoke a method on a particular component.

https://hutonggames.fogbugz.com/default.asp?W57
https://hutonggames.fogbugz.com/default.asp?W56

Then within fsm, you set "jump_up" event as a global event and in that state triggered by that event, use on the of the action above. you could also use that actually directly from where you are sending that event in the first place, it depends why you created this event.


Bye,

 Jean
 

liero116

  • Playmaker Newbie
  • *
  • Posts: 21
Re: Reasing FSM state from script
« Reply #2 on: March 01, 2012, 12:35:53 PM »
I'm using a script to control a character's physical movement and using FSM for animations and other things.  I basically want the character to jump when shes in a particular FSM state rather than when I press the jump key.  I tried doing movement in FSM and it worked fine, but I could not get it to jump properly and it was ignoring gravity on top of that.  Frankly, I'd rather have the movement in FSM but it doesnt seem to want to work the way I want it to.  If you have a solution for making a character jump and use gravity in FSM let me know and I'll do that instead.  I have tried using the set/use gravity actions both with and without a rigidbody attached and had no luck.