playMaker

Author Topic: Global Transitions VS Event Data Enum Switch for my Sound Manager  (Read 280 times)

Christoph

  • Beta Group
  • Sr. Member
  • *
  • Posts: 254
I know that there are always different ways of designing things and I'm interested to hear what others do and why they prefer one over the other.

In this case I'm developing an Audio Manager and I'm between these two options:
1. Have an FSM with many global transitions, each for the specific sound I want to trigger. For example I have "Button Tap" and I would simply send the event Button Tap, be it with the action "Send Event" with global events or "Send Event by Name" for local events (which I am not sure either what is better).

VS.

2. Have an FSM with only one global transition called "Play Audio" and every time I send this event I also would either use "Set Event Data" and "Get Event Info" or I directly would use "Set FSM Enum". In either case I then would do a Enum Switch to a separate state where I play each corresponding sound.

Is there a third method I should consider? And which one should I use and why?

I'm mostly interested in the most performant and fastest setup but also want it to be as flexible as possible to use it in many different games.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Global Transitions VS Event Data Enum Switch for my Sound Manager
« Reply #1 on: May 30, 2023, 02:13:18 PM »
Hi.
Both Send Event and Send Event By Name should be fine and probably better than using 'get event info' as its more prone to have issues if for example 2 events are send at the same time.

for event names use something like this :
Audio/Vendor/Open
Audio/Vendor/Close

it will be easier to set the events if you use Send Event/

in the audio fsm you can set the transitions to the start state (local)
or set the transition global (on top of a state)

If local it should ensure that not 2 sound will be triggered at the same time (which can cause weird sound)
make sure to loop back to the state with all the sound transitions

If you are sure it wont be happening you can set transitions global to the states directly