How to code different skins for the same character by ONLY swapping Sprite2D/3D

Godot Version



Hey everyone, I was unsuccesfully trying to find a little info on how to do something specific:

I have nearly finished coding my enemy, and I thought it would be really nice to add a bunch of different skins to it and randomize them at spawn, so it´s appearance is always a little different, for a better game experience, but I have a problem:

When I try to do that, It won’t work because the AnimationPlayer’s “keys” are taken from one especific Sprite, so if I add a new Sprite, the animations don’t work, even though it is the same moves on each frame, unless I re do the “keys” all over again.

I am 10000% sure there is a way to do this, and it could save me literally YEARS of work, but I can´t find any information online about this.

Does anyone know how to do this the easy way?

Instead of adding a new sprite, just change the texture of the existing sprite. As long as the new texture has the same size as the original texture, it should work.

Something like this should work:

extends Sprite2D

var skins: Array = [

func _ready() -> void:
	texture = skins.pick_random()
1 Like

:brain: :muscle: :brain: :muscle: :brain: :muscle: :brain:That sounds really good, let’s give it a go and update you with results:

1 Like

Worked perfectly first try, you just saved me a very very big amount of time, seriously thank you!!!

1 Like