How to control individual instance of a sprite sheet

Godot Version

4.3

Question

In my scene I have a sprite sheet as the texture of a sprite2d node. I want to have 4 instances of this sprite sheet for each of its frame. And I also want to set their positions to my liking. So how can I achieve this in gdscript? (sorry for bad English)

So, I don’t understand exactly what you are wanting to accomplish. Do you want to cycle through which sprite in the sprite sheet is used via the code?

You could use AnimationPlayer rather than a Sprite2D. Make an animation for each sprite in the sheet you want and call AnimationPlayer.play(“your animation name here”)

In AnimationPlayer animations you can create keys that change multiple things, and you can also change keys via code.

1 Like

I have 4 horizontal frames in this sprite sheet and I want to place each one in a different position

What do you mean place them in a diffeeent position? At same time? Within spritesheet? Do you want the four visible at same time but individually be able to choose where they are?

1 Like

Yes, that’s exactly what I want.

I think you’d have to put the sprite sheet in four different nodes and choose just the image you want in each, that way you can then control each image.

Parent
Sprite1
Sprite2
Sprite3
Sprite4

1 Like