playMaker

Author Topic: How to set event data when using PlayMakerFSM.BroadcastEvent?  (Read 596 times)

forumuser

  • Playmaker Newbie
  • *
  • Posts: 5
How to set event data when using PlayMakerFSM.BroadcastEvent?
« on: November 01, 2022, 04:23:37 AM »
At the moment, I'm using the following:

Code: [Select]
        Fsm.EventData.StringData = "my data";
        // FsmEvent myevent = new FsmEvent("myevent");
        PlayMakerFSM.BroadcastEvent("myevent");

Is this the best way to do it?

Is there any documentation for sending event data and different ways of doing it? Also maybe more specifically, info about FsmEventData? Searching wiki doesn't return anything.

EDIT: updated the example code so BroadcastEvent takes a string rather than a FsmEvent instance. Apparently that didn't work. How do I use an FsmEvent?
« Last Edit: November 01, 2022, 08:16:56 PM by forumuser »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How to set event data when using PlayMakerFSM.BroadcastEvent?
« Reply #1 on: November 02, 2022, 01:30:34 AM »
Hi.
Can you give more details on what you want to do, Broadcasting is far from ideal to use 'performance wise' (you will be checking all objects to broadcast this event)

forumuser

  • Playmaker Newbie
  • *
  • Posts: 5
Re: How to set event data when using PlayMakerFSM.BroadcastEvent?
« Reply #2 on: November 02, 2022, 07:37:29 PM »
Quote
Can you give more details on what you want to do

Basically, the way I use PlayMaker in my game is to add additional/custom functionality to DLC characters without having to create custom scripts.

Regarding my question, I've got, say, a couple of characters that i want to implement functionality where if you speak into your device microphone, it moves the mouths of the characters.

At the moment I've got the code which reads and interprets the microphone volume level and produces a normalised float -- so the idea would be the character would take this value and open its mouth based on the value.

My plan for integration using Playmaker, is that my existing code that interprets the microphone level will broadcast the normalised value (using .BroadcastEvent), so any character with the event listener can use the value however it wants -- e.g. it can open the mouth, or do something completely different, like wave its arms based on microphone volume.

Quote
Broadcasting is far from ideal to use 'performance wise'

- Is that just .BroadcastEvent not being good performance-wise?
- Does the same apply to .SendEvent?
- With .BroadcastEvent, does it matter on the amount of FSMs I have in the scene?


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How to set event data when using PlayMakerFSM.BroadcastEvent?
« Reply #3 on: November 03, 2022, 04:24:32 AM »
Hi.
Broadcast will check all objects.
same for send event if you set it to 'broadcast all'

it would be better to have an array list with the objects that you want to send an event to.

Especially if you are sending events regular.

forumuser

  • Playmaker Newbie
  • *
  • Posts: 5
Re: How to set event data when using PlayMakerFSM.BroadcastEvent?
« Reply #4 on: November 03, 2022, 06:16:31 PM »
So you mean storing a list of FSMs and then using PlayMakerFSM.SendEvent to send the event right?

And what are the different ways to send additional data via script?

Is there documentation or examples on that?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How to set event data when using PlayMakerFSM.BroadcastEvent?
« Reply #5 on: November 05, 2022, 12:35:13 AM »
Hi.
You can use Get/Set Fsm Actions.

what I usually do is 1st set data with get/set fsm actions then send an event.

On the Ecosystem you can find more custom Fsm Actions (for example Fsm Int Compare / Fsm Int Add / etc)

forumuser

  • Playmaker Newbie
  • *
  • Posts: 5
Re: How to set event data when using PlayMakerFSM.BroadcastEvent?
« Reply #6 on: November 06, 2022, 12:16:44 AM »
Awesome, I've been using those.

Thanks