Godot Version
v4.4
Question
I am currently creating a simple character that uses a spritesheet to animate. This spritesheet works completely fine in the editor and when a camera is *not* in the scene, but once there is one, the sprite2D is offset downwards by one pixel. This occasionally fixes itself, and then breaks again. Any help would be appreciated!
Camera and Viewport
No camera
extends CharacterBody2D
@onready var animated_sprite_2d: AnimatedSprite2D = $AnimatedSprite2D
const SPEED = 100.0
var runSpeed = 2
func _physics_process(_delta: float) -> void:
var speedMultiplier = 1
if Input.is_action_pressed("cancel") and false:
speedMultiplier = runSpeed
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction := Input.get_vector("left", "right", "up", "down")
if direction:
velocity = direction * SPEED * speedMultiplier
if direction.x > 0: animated_sprite_2d.play("move_right")
elif direction.x < 0: animated_sprite_2d.play("move_left")
elif direction.y < 0: animated_sprite_2d.play("move_up")
else: animated_sprite_2d.play("move_down")
else:
velocity = Vector2.ZERO
animated_sprite_2d.stop()
animated_sprite_2d.frame = 0
move_and_slide()
Thank you!