Can you group states in state machines?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Chevi

So in short, I want to group all of the attacks in my state machine as a group so later in code I can write an “if” statement checking if any of the attacks in the “attack” group is currently running.

:bust_in_silhouette: Reply From: Ertain

You could attach these states to nodes, and have them in a node group. Either that, or have hierarchical states. When one attack is necessary, and is a more complicated version of various other attacks, a hierarchy would help.

How can I assign them to a group exactly? I’m using the animation tree node.

Chevi | 2021-03-30 19:11

Ah, sorry. Thought you had a complete state machine setup, with separate scripts and everything.

Best I can think of is adding a reference to the animations in an array, and checking whether the currently running animation is a part of that array.

Ertain | 2021-03-30 20:40

I tried this “array” method and it worked great! But now you got me interested in this “complete” setup. What does it include and what are the benefits?

Chevi | 2021-03-31 00:02

The state machine, as implemented by GDquest (a.k.a. Nathan Lovato), includes states that are loosely coupled to each other, as well as state hierarchy. Here’s an old video where he explains state machines. I based my current state machine stuff on the GDquest mannequin demo. This is a nice setup where more intricate states can be used alongside general ones.

Ertain | 2021-03-31 01:12