GC FSM - Event-driven, hierarchical finite state machines in blueprint

Hi @JeromeParent ,
I am sorry to confirm that you encountered a bug in the implementation of Submachine states. The good news is that I already have a fix for it. I will have a round of test to check for possibile regression and then I’ll push the fix. If all goes well, you should be able to get it around middle of next week.

Great, thanks!

Hi @JeromeParent
, the fix for the bug you reported is now online. Thanks again for the report.

Hi

I could’t find “Add Internal Event…” in the GC FSM category.
Where could i find this menu???

Any ETA on 4.21 version @gamecentric ? :rolleyes:

I’m really sorry to be taking so long to update. I hope to be able to submit a 4.21 version by the start of next week. Will keep you posted.

Thank you, I just subscribed and will follow the thread in the future. :wink:

A version of GC FSM supporting Unreal 4.21 is now available on the Marketplace. Enjoy!

Cool, thank you! :slight_smile:

As a feature request - I’d really like to be able to set the ticking group of a given FSM.

In some cases I’m doing some time-concious things, and it would be nice to have a regular tick function where I can add prerequisites, change the tick group etc. I’ll probably customize the plugin to add this for myself for now, but would be really beneficial!

That is it an interesting suggestion, thanks. I actually experimented with the idea in the past, but it wasn’t implemented. There are no technical issues, actually, I just thought it was of little interest. I may reconsider the feature though.

I have one question, not sure if this is possible or i did not found it.

I have FSM in player pawn, it runs locomotion states. Lets say i have 3 states (stop, walk, run)
Now. umg widget needs information about those states, also animation blueprint needs it.

Is is possible to trigger FSM event like “Walk” from player pawn, and other blueprints be aware of it without using references.
So kind of global event that every FSM can be aware of. Like dispatcher but without assigning to event.

I know i can make dispatchers in player pawn, then hook them in all other blueprints. But i will have about 10 or 20 dispatchers to manage locomotion weapons, variables for pawn. Would be nice to not have all that clutter there, just pure FSM.

I am not sure I understand your problem fully. You first describe Walk as being a **state **and that objects different from the FSM need to get informations about that state. Immediately afterwards, you describe Walk as being an **event **and you ask how to have many objects trigger such event globally (without having a reference to the actual FSM). These seems two completely different things to me, that can be addressed in very different ways. Could you please elaborate on your needs?

PS: I don’t think you need dispatchers at all for these kind of issues, surely not tens of them.

Ok i try once again.

I have state machine in player pawn, that represents locomotion state of that pawn. So walk event is fired when player pawn from standing state goes into walking state.

But i also have animation blueprint that i want to be aware of walk event. Easiest way was to make dispatcher in pawn and hook anim blueprint to it.
However there is also hud widget that i want to be aware of locomotion state (and that walk event).

When i trigger FSM event in player pawn my state machine that is located in player pawn works just fine. But i cannot find a way to change state machines in animation blueprint and hud widget without using dispatchers.

So is there a way to use same FSM event trigger to change state for multiple machines in different blueprints? Because that would be awesome.

I also do not want to use references to those state machines, it is problematic, for eg when i use different animation blueprint classes for different pawns, those references would be different.
I want to avoid all that “cast to”, then check if it is valid then cast to next class etc (or dispatchers for each event i need). With single event that is visible to all state machines i could get clean code.

And next example (of what i want do with FSM).

I have weapon blueprint. It has state machine that represents firing (also sub-state machines for automatic fire, single shoot, continuous (like flamethrower that starts and stops)).
That machine cares about reloading ammo count clips all that things for weapons.

And there again i have state machine in animation blueprint for weapon skeletal mesh and another one for player pawn. Both of those state machines should be triggered by different events from weapon state machine. For eg end of clip should trigger animation state for reloading on pawn, and stop firing state on weapon model animation blueprint. It also should trigger some hud update for hud state machine.

So i need single event trigger to change state of multiple state machines in very different blueprints. Sometimes it is quite complicated to get references to, they also may have different class (like different blueprint class for sniper rifle that is single shoot and different for assault rifle that is different class).

You can exploit the fact that TriggerEvent block actually takes an untyped object reference. You can use this fact this way:

  1. In the Pawn, add a variable of type “array of object references”, call it attachedFSMs.
  2. At Pawn initalization, add self to the array and the references of all FSMs that need to be notified. You don’t need a cast to do that, since everything can be safely upcasted to an object reference. If you can’t get proper references during Pawn initialization, make every other FSMs add themselves to the Pawn attachedFSMs array during **their **initialization.
  3. Add a function TriggerEventDispatch in the Pawn that invokes TriggerEvent in a loop to every object in the attachedFSMs array
  4. Replace every other call to TriggerEvent to TriggerEventDispatch

If you want to re-use this pattern in other non-pawn objects, just package this behaviour in a component.

Alternatively, create an EventBroadcaster object. Every FSMs that need to receive an event can register to the broadcaster during its initialization. The EventBroadcaster shall have a function that calls TriggerEvent on every registered object. When you want to notify all FSMs, just call the broadcaster instead of using TriggerEvent directly.

I did that with dispatcher that sends out name of event as parameter. Then each object hooked to dispatcher triggers FSM local event with that name from dispatcher.

So i see this universal event is not currently possible. Can this be added as feature some kind of super event or broadcast message?

I will consider adding an EventBroadcaster component, so that such a facility may be available out of the box. I would rather not introduce “super” or “global” events or dispatchers, since that is a feature that is too easily abused. I understand that it may be convenient in your use case, but my approach is to never sacrifice (what I believe is) “good design” for “conveniency”.

Thanks. I understand your worries, or rather that such event will let some programmers ruin purpose of this plugin.

Anyway great plugin, changing most of my project logic to GC FSMs.