Is it good to store data in animations?

Godot Version 4.2

Introduction

I Have different sprite sheets for different player animations.
Each of them have different Hframes and Vframes.

I store them in AnimationNode like this:
example from editor

each animation have it’s own texture and HVframes

Im playing animations depending on Player state (idle, walk, run) with code.

Question

Is it good descision to store sprite sheet and Hframes, Vframes in animations?
Wich pros cons does that method can have?

Not a bad idea, animations are just data through time. For this scenario it may be better to use a AnimatedSprite2D though.

1 Like

How does texture get stored?
all animations (and their data) stored in ram when object on scene, or every texture will load when new animation started?

I believe the textures will be loaded as the animation plays (when texture is changed).

1 Like

This is a potential cause of freezes cause animation files is pretty large (6-13mb).
If I make
const texture = preload(texture)
in Player’s script could it help, or there will be just another texture instance in ram?

You can address freeze issues in other ways, e.g. use ResourcePreloader

For the question itself, to me this looks not ideal, but I can’t come up with a better solution.

(I assume you’re doing root motion, so this is why you need to match particular frame against particular position. If root motion is not what you’re doing, then it is worth considering AnimatedSprite instead of AnimationPlayer)

2 Likes