#Weird sprite issue when sprite is moving in diagnol directions (2D top-down)

1 messages · Page 1 of 1 (latest)

ancient dagger
#

Hiya.

As shown, when my characterbody2d is moving diagonally, there is some sort of strange behavior where the very bottom of its sprite is looping back to the top. I can't figure it out but I assume it's some sort of render issue? The sprite is correctly sized at 64x64 and looks fine when moving in all other directions.

Relevant code is as follows:

func _physics_process(delta: float) -> void:
    # Input for movement
    var move_direction = Vector2.ZERO
    move_direction.x = ceilf(Input.get_action_strength("move_right")) - ceilf(Input.get_action_strength("move_left"))
    move_direction.y = ceilf(Input.get_action_strength("move_down")) - ceilf(Input.get_action_strength("move_up"))

    # Normalize the movement vector and scale it by move_speed
    move_direction = move_direction.normalized() * SPEED * delta
    velocity = round(move_direction)

    desired_velocity = velocity
    determine_animation()

    # Move the character
    move_and_slide()

func determine_animation():
    if velocity == Vector2.ZERO:
        animation_player.stop()
    else:
        if (velocity.y == 0):
            if velocity.x > 0:
                animation = "walk_right"
            elif velocity.x < 0:
                animation = "walk_left"
        
        if velocity.x == 0:
            if velocity.y > 0:
                animation = "walk_down"
            elif velocity.y < 0:
                animation = "walk_up"
        animation_player.play(animation)
pliant sparrow
#

have you disabled texture repeat?