playMaker

Author Topic: Nice tool, about scripting actions  (Read 2129 times)

bigdaddio

  • Playmaker Newbie
  • *
  • Posts: 1
Nice tool, about scripting actions
« on: December 29, 2012, 01:40:57 PM »
I have had playmaker for some time I believe I bought it last summer, finally got around to messing with it. Very nice. I had been writing my own FSM's and was not really happy with the maintenance of them. This has made it very easy to construct and maintain. There are other advantages as well.

So when writing an action why would I use FsmVector3 as opposed to Vector3? or really any of the Fsm types in my actions it seems like an added layer of complexity to me. I have lines like:
Code: [Select]
Vector3 playerDirection = (player.transform.position - npc.transform.position);They seem to work just fine. Would I only use FsmVector3 for exposed variables?

Second question is more general, where is the API documentation? When I click API on the WIKI I get a few choices but no API for all the stuff. Like Fsm.Event has 3 overloads... why and what are they? no documentation. The best I get is the intellisense  from Visual Studio, or digging through the Object Browser. I see we have:

 Event(HutongGames.PlayMaker.FsmEvent fsmEvent)
 Event(string fsmEventName)
 Event(HutongGames.PlayMaker.FsmEventTarget eventTarget, HutongGames.PlayMaker.FsmEvent fsmEvent)
 Event(HutongGames.PlayMaker.FsmEventTarget eventTarget, string fsmEventName)

What are they and what do they do? I have to doink around with it to see how each works. It would be way better if I could look them up and get a definition. Like an API page maybe?



kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Nice tool, about scripting actions
« Reply #1 on: December 29, 2012, 02:38:04 PM »
well, as far as my limited understanding sees it, the extra layer is intended. This is my theory
In your example, the Vector3 would be a variable in that script. If you change it, you change the variable in the script.
However, if we define a FsmVector3 in a script, that is the variable there. Then in the action browser, we set the Value of that FsmVector3 to a real variable, whcih we define in the Fsm main class (I have no idea how the individual FSM classes are called). So now if we set FsmVector3.Value to something, we're not actually changing an instantiate variable in the script, but the "real" Vector3 in the Fsm class.

Did that make sense? :D Ah and yes, FsmVariables only for exposed variables. You can also expose variables that are not FsmVariables, but you can't get or set them from another variable.

Now as for your second thing, there I can definitely help you :D No idea where the api is , but you really don't need it. Each and every important thing has a wonderful clearly structured code snippet shipped with Playmaker , called actions :P . Just open the send event actions to see what those individual arguments do. I think pretty much everyone's doing it that way .
Best,
Sven

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Nice tool, about scripting actions
« Reply #2 on: December 30, 2012, 10:50:31 AM »
Better API docs are in the works...

As kiriri suggests, the best approach right now is to use the actions that ship with Playmaker as a guide to make your own actions.

And of course you can post questions in the forums :)

Quote
So when writing an action why would I use FsmVector3 as opposed to Vector3?

Use FsmVector3 if you want to reference a named FSM variable. In the Playmaker editor, FsmVector3 can be set to an explicit Vector3 value or point to a named variable that can be shared by other actions etc. Generally you should use FsmVector3 over Vector3. The main difference code wise is you need to use the Value property to access the wrapped value.

Quote
Event(HutongGames.PlayMaker.FsmEvent fsmEvent)

You can send FSM events as strings or FsmEvents. Built in actions generally use FsmEvents for better performance, but you have the option to use a string if you need to. You can also get an FsmEvent by name using:

Code: [Select]
FsmEvent.GetFsmEvent(string eventName)