playMaker

Author Topic: Calling PlayMaker Actions from script?  (Read 1022 times)

t3rmina

  • Playmaker Newbie
  • *
  • Posts: 3
Calling PlayMaker Actions from script?
« on: December 17, 2020, 11:36:34 PM »
Hi there, in an ideal world, I would love it if I could have a custom action attached to my node that would populate it with the actions i need (ex. Set String Value, Set Audio Clip, etc.) with information I input in the custom action script. Or from the script itself, whatever.

I can't seem to find anywhere if Im able to access the state actions from script (either to call the action directly from script or just to assign values). Any help? Thank you!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Calling PlayMaker Actions from script?
« Reply #1 on: December 18, 2020, 05:56:53 AM »
Hi.
you can communicate with variables on a fsm.

Also you can call states. (Set State) or use events.

But to add actions to a fsm from a script might not be possible, especially @ runtime.

Have a look at the PlayMaker API

t3rmina

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Calling PlayMaker Actions from script?
« Reply #2 on: December 19, 2020, 12:56:33 AM »
Hi.
you can communicate with variables on a fsm.

Also you can call states. (Set State) or use events.

But to add actions to a fsm from a script might not be possible, especially @ runtime.

Have a look at the PlayMaker API

Yeah from my understanding, adding actions doesn't seem possible, I also cant find a way to access the values for these actions. I would love to assign values to actions to runtime, or really any way to communicate with action variables.

For example, say I have "set audio clip" action in my fsmState. There are a couple of things that I would *want* to do (note, dont know if Playmaker can accomplish these, this is what im asking):
  • I have a custom action class that has all my information housed, so I access the audio clip stored here, and assign it to my Set Audio Clip action.
  • I have a custom action class that calls the function that Set Audio Clip represents, but in script. (now I really dont think this is possible)

From my understanding, I am not sure if I can accomplish this, but I basically want to have one custom action on each fsmState that can populate/call all of the actions I want on that state.

Thank you so much!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Calling PlayMaker Actions from script?
« Reply #3 on: December 19, 2020, 07:05:32 AM »
Hi,
You can access variables from/to scripts
And you can send events.

So you can change a variable on a existing fsm and send events to trigger it.

But you also can use arrays or hashtables on a Game Object best is to use Array Maker for that.

Something else you that might be useful is using scriptable objects :
https://hutonggames.com/playmakerforum/index.php?topic=20829.0

Also i think you can add a fsm @runtime and set a template on it, so maybe that direction could accomplish what you are looking for.

So add fsm, set template, set audio clip to a variable on the template, send event to a state with audio play action.