Anyway to make AnimationTree less messy?

Godot Version

4.4.1

Question


So I currently only 5 different animations for a base enemy. For a boss enemy I am thinking of adding even more animations (more attacks, jumping, entry)

The animation tree is already getting very cluttered. Is there any way to make it less messy? And is my current implementation standard?

Thanks!

Yes. There’s a pattern called IdleWalkRun you can use. You create a BlendSpace2D and call it IdleWalkRun or IWR or IdleWalk perhaps in your case.

When you edit the BlendSpace2D You put all of the possible movement animations in every direction. (If you’re doing a 2D game you can use a BlendSpace1D.) Then most your transitions can hang off of it, because as soon as they hit it, if something else gets called, you transition into that. Then when you move the character, you just pass an amount from 0 to 1 for each movement axis and you get a blended animation. If it’s at 0,0, it idles.

## Handles Idle/Walk/Run Animation
func do_animation() -> void:
	var vl = character.direction * character.rig.transform.basis
	character.animation_tree.set(character.IDLE_WALK_RUN_BLEND_POSITION, Vector2(vl.x, -vl.z))

There’s a whole tutorial here: Character Animation :: Godot 4 Recipes

Thanks for your response!

My game is a 2d platformer. Currently, my sprite animations have different amounts of frames. When I put the different animations into BlendSpace1D, the character glitches around in the editor. I think this is due to the frames not being the same.

Do you have any idea to solve this issue?

edit:

I figured out that if I use ‘discrete’ it doesnt have this issue but if i do ‘continuous’ it does.

Sadly, I don’t. I have only used AnimationTree for 3D animations. So far for all my 2D animations I have just used code and AnimatedSprite2D. But I’m working on an entry for the Metroidvania Game Jam, so ask me in a month. I might have tried it.

1 Like