0 votes

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.

in Engine by (62 points)

1 Answer

0 votes

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.

by (2,462 points)

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

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.

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?

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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.