Persistent frame in every animation node option

Godot Version

4.4.1

Question

I’m making a 2D game with simple art, i made a sprite sheet with 12 frames and was trying to change between frames using an variable index, i started using animated sprite 2D, but when put to practice the first frame of the sequence was projected on top of the next frame, i tried every thing i could think of, then changed to the Sprite2D node, and the same problem happened, i tried using region, to start and stop the animation, to use animation player, to start a new project, but nothing changed, i really don’t know what this could be.

SpriteSheet Base

First Frame - Index 0

The Problem - Index 1

Could you share your scene tree and code for changing frames? A Sprite2D sounds great for this, it even has h/v frames

Does your Book Sprite2D have the staff also? For the looks of it that’s the issue.

Looks like standard stuff! If you aren’t duplicating nodes in the script anywhere then I’d guess it’s a rendering issue, maybe changing to/from forward+ and compatibility mode could help? Can you also share more of the code, be sure to paste scripts instead of screenshots

no, the book is a separate thing

No duplicating nodes, the code is very simple:

extends CharacterBody2D
class_name Player

# Player 


# Skins
@onready var skin_anim = $Skin
var skinID : int

# Staves
@export var staffList : Array[Staff] = []
@onready var staff_anim = $Staff
@export var staffID : int

# Books
@onready var book_anim = $Book
var bookID : int

func update_sprites():
	if staffID < 0 : staffID = 0
	elif staffID > 11 : staffID = 11
	staff_anim.frame = staffID

func _input(event: InputEvent) -> void:
	if event is InputEventScreenTouch and event.pressed == true:
		look_at(event.position * get_canvas_transform())

I just tried compatibility mode but nothing…

It won’t solve your problem, but you can use clampi() in place of your manual clamping on staffID.

1 Like

thanks

One thing you might try is making the Staff node invisible and see if you still see anything you shouldn’t.

Edit: I’m wondering if maybe you have two entire Player nodes one on top of the other or something. You might try calling print_tree_pretty() on the scene root and see if there’s anything suspicious.

2 Likes

I solve it by using Sprite2D.hide() on the func _ready and then showing on the button Func

func _ready() -> void:
	$Staff.hide()


func _physics_process(delta: float) -> void:
	staffID = clampi(staffID, 0, 11)
	staff_anim.frame = staffID
func _on__button_up_add() -> void:
	Main.player.staffID += 1
	Main.player.staff_anim.show()
2 Likes

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