Setting Offset X/Y in GDScript?

Godot Version



Is there a way to set offset for an animatedsprite2d in code? I want to do so because when my character wall slides the character is floating and when I change the offset it fixes the issue.

yes, offset is a variable like any other so it can be set in code. If the script you’re going to do this on is on the Animatedsprite2d, just do

offset = Vector2(whatever ur new offset is)

if it’s not on the animatedsprite2d, drag the animatedsprite2d into the script from the scene hierarchy to get its path and

$AnimatedSprite2D.offset = Vector2(whatever ur new offset is)

(don’t copy and paste the code! make sure to get the actual path for the sprite or it won’t work!)

1 Like

thank you