Animation in a resource

Godot Version

4.7.2

Question

I’m making a fighting game roguelike. The player needs to collect various moves to increase their options in a fight. So, I decided to make a move resource so I can make lots of moves easily. I’m relatively new to godot and I’m especially new to using resources, this is my first time dabbling with them.

I have a move resource with the properties that a move would need: damage, knock back, etc.

extends Resource
class_name Move


@export var damage : float
@export var frame_data : FrameData
@export var knock_back : float
@export_enum("High", "Low", "All") var guard 
@export var animation : Animation

func _init(_frame_data : FrameData, _damage : float, _knock_back : float, _guard : Guard, _animation : Animation ) -> void:
	damage = _damage
	frame_data = _frame_data
	knock_back = _knock_back
	guard = _guard
	animation = _animation

And this is FrameData for context:

extends Resource
class_name FrameData

@export var start_up_frames : int = 1
@export var active_frames : int = 1
@export var recovery_frames : int = 1
@export var frame_advantage : int #If negative -> disadvantage

func _init(_start_up_frames : int, _active_frames : int, _recovery_frames : int, _frame_advantage : int) -> void:
	start_up_frames = _start_up_frames
	active_frames = _active_frames
	recovery_frames = _recovery_frames
	frame_advantage = _frame_advantage

So the system I want is: The player is idle, they press the kick button, the player script finds the move corresponding to the kick button and plays its animation with the hit boxes and everything. The thing I’m stuck on is actually implementing the animation. I don’t want the animation player on the player to just have like a hundred animations for each possible move, I want the move resource/script to actually hold it.

Maybe pull out the animations into something exterior to your resources and only store the ID of the corresponding AnimationPlayer and the ID of the corresponding Animation.

I believe you can also save single animations as their own scenes.