Custom Item Action with Playmaker

Yago

New member
Hello!

What I am trying to achieve is Sending an Event to a Playmaker FSM when an Item action is casted.
I can access easily from PlayMaker to UIS, but to UIS to Playmaker I am having great difficulties :(

In the Youtube tutorial about Item Actions explains how to create a custom item action via Script,
I guess thats the only way of doing it right?
It would be awesome if was already created a Generic Custom Action to send events to specific FSMs!

Right now what I have been trying to do is creating a custom action via script from where I can send
a event to a FSM with the line of code "Myfsm.SendEvent("ACTION");",
but I am failing hard to launch it from the UIS action Item.

Sorry If am asking to much, but could you please help me to understand which is the best way to interact UIS>PM,
or.. how to use scripting as a bridge between the both of them?

I am sorry if I am asking too much or if is confusing what I am asking,
but I would be really greatful if you could throw some light here ( And I am pretty sure other PM users too!)

Thank you in advance!
 
I guess the part that is causing you issues is getting the FSM object from the ItemAction.
ItemActionSets are Scriptable Objects to they cannot reference things in scenes during edit time.

So my solution is to get a FSM on the character (ItemUser) gameobject and send an event to that. Then from there you can do whatever you want with that event: send it somewhere else, broadcast it, etc...

You can define the event name as an Item Attribute, or have a default event name in case the event name on the item cannot be found.

I can't pass any data using that event, but I'm guessing that's fine for now.

Let me know if the new "PlayerMakerEventItemAction" script I attached below works for you. If it does I'll add it in the next update of the integration.
 

Attachments

  • PlayMakerEventItemAction.cs
    1.7 KB · Views: 8
Hello!

Thank you very much for getting into this!!!!
I have downloaded the Script attached, and I dont know if is because I am missing something, but I can not make it work :(

These are the steps that I did:

- Created a FSM in the Character and made one global event named "KOKO"
fsm2.JPGfsm1.JPG

2) Created the Item Action with the script provided and filled the spaces with "KOKO", I tried different combinations:
Like only with Attribute Event Name, with both, with only Default Event Name...

I believe I followed the steps that you mentioned, but still the Event "KOKO" doesnt get started..
I dont know if I should rename the FSM with an specific terminology, or if I should edit it somewhere,
does it automatically detect the FSM, or made a broadcast all to all the FSMs within the Character?

I hope I am not missing something really basic, sorry if so..!
Thank you in advance!!

-
 
Ah you are right, there was a bug preventing the default name to be used.

Here I fixed it and took the time to add some more options:
1625745364891.png

The "Attribute Event Name" is used to try and find the event name on the item attributes. if It does not find it, the default event name will be used.
Allowing you to set the event name on the item attribute lets you customize the event called on each item:
1625745516244.png

The events don't have to be set as global, if you don't want to, since the event is called on the FSM attached to the player character.

I also added the option to append the item name at the end of the event, I'm not sure if will be useful. I also added the option to log the event name in case something is wrong and you wonder if the event is being called correctly.
 

Attachments

  • PlayMakerEventItemAction.cs
    2.3 KB · Views: 6
Hello!!

It works perfectly!!
Thank you very much for doing this so quick, it is super helpful and easy to set it up!!!
And yes! I still need to dig more about it, but I think that having the possibility of appending the item name at the end of the event it is great.
I did a test and works nicely, I believe will make it easier to generate lots of item actions from a generic base.
Again, Thank you very much!
 
Top