What's the CORRECT way of having a sprite I can animate on the GUI layer?

Godot Version

v4.2.2.stable.mono.official [15073afe3]

Question

There’s probably a very obvious and easy solution to this but I simply cannot figure out how to do this. What’s the correct way of having a control node which can be animated with an AnimationPlayer node? Having a PanelContainer or something similar doesn’t really work, as the sprite will be moving along with my player object or whatever it’s attached to IN the world, and not on the screen / gui itself, and using the “AnimatedSprite” resource is marked as obsolete, so I don’t want to use it, besides, it’s really really inefficient the way I need to set it up, as I have a spriteSheet for this, and that resources needs individual files to work.

So my question in short is: How can I have a Control node with a texture attached, which can be animated easily with an AnimationPlayer node?

TextureRect node probably is what you need for this.

If you’re doing GUI things i recommend you put everything related to GUI inside a CanvasLayer node

TextureRect, while supports having a texture attached to it, it does not have any way of changing that texture’s properties the way a normal Sprite2D node would, more specifically, it doesn’t have the following properties which I need:

  • Hframes
  • Vframes
  • Frame / FrameCoords

This ended up being the solution oddly enough, but I find it weird that I specifically need to add a base CanvasLayer node, when a simple Control node inherits it already, but thank you!

Control doesn’t inherits CanvasLayer, Control inherits CanvasItem

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.