Tween is moving off sideways after completing animation

Godot Version



Hello, running into a weird issue with tweening damage numbers. It seems that after doing the initial up->down movement, it seems the label moves sideways and I am not sure why that is the case. Brief video of the issue.

This is the whole code (taken from a youtube tutorial that doesn’t have this issue)

func display_number(value: int, position: Vector2, is_critical: bool = false):
    var number =
    number.global_position = position
    number.text = str(value)
    number.z_index = 19
    number.label_settings =

    var colour = "#FFF"
    if is_critical:
        colour = "#B22"

    if value == 0:
        colour = "#FFF8"

    number.label_settings.font_color = colour
    number.label_settings.font_size = 18
    number.label_settings.outline_color = "#000"
    number.label_settings.outline_size = 1
    call_deferred("add_child", number)
    await number.resized
    number.pivot_offset = Vector2(number.size / 2)

    var tween = get_tree().create_tween()
        number, "global_position:y", number.position.y - 48, 0.5
        number, "global_position:y", number.position.y, 1
        number, "scale", Vector2.ZERO, 0.5

    await tween.finished

Not really sure why the label is moving, I can see it being added to the top of the tree by itself (not under enemy nodes). So confused why it moves in x direction after finishing the initial up->down movement.

Thanks for taking a look!

Control nodes Control.scale uses the Control.pivot_offset property as its origin. By default is the top-left corner. You’ll need to change the Control.pivot_offset property to the center of the Label for the scale to look fine.