global position and size alter after awhile


Hi, dear godot master

I am trying to do Making Buttons with animations in godot 4.0.2

and what confuse me it's:

node global position and size alter after awhile, it makes:

1. If I dont await 0.01second.finished in _ready() virtual method,

selector will appear in wrong position at first

2. if I dont set pivot_offset in script, no matter what's the value in inspector, it turns to 0,0

it's a bug or what I doing wrong?

extends Control

@export var bg:ButtonGroup

@onready var icon: Sprite2D = $Icon

@onready var v_box_container: VBoxContainer = $VBoxContainer

@onready var buttons := bg.get_buttons()

# Called when the node enters the scene tree for the first time.

func _ready() -> void:

 await create_tween().tween_interval(0.1).finished

 for i in buttons:





  i.pivot_offset = i.size/2


# Called every frame. 'delta' is the elapsed time since the previous frame.

func _process(delta: float) -> void:


func movetobutton(button:Button):

 var tween = create_tween()


 tween.tween_property(button,"scale",Vector2.ONE * 1.1,0.15).from_current()

func moveaway(button:Button):

 var tween = create_tween()


func clickbutton(button:Button):

 var t = create_tween().set_parallel(true).set_trans(Tween.TRANS_ELASTIC)



 await t.finished

 t = create_tween().set_parallel(true).set_trans(Tween.TRANS_ELASTIC)



  • Nathan Lovato replied

    The code you shared seems like the await shouldn't change anything in this script specifically. Do you have other UI elements with scripts in your project? Or is this the only code running? If this is the only code running, in an isolated scene could you please show us the scene tree? Without more information we may not be able to help you figure out the cause of the issue.

  • d
    darkstarrd replied

    Sure , Thank You

    ss (1).jpg

    It's in Editor

    ss (2).jpg

    If I comment out these two liness (4).jpg

    It will become thisss (3).jpg

    I find out this issue by print global position and size on ready and process method, and figure out this work around,but it seems odd to me

  • Nathan Lovato replied

    Okay it makes sense, so the problem is that you have a parent box container node (VBoxContainer) that is supposed to control the child buttons, but you're kind of bypassing it by trying to modify a property of the button nodes that the container doesn't automatically account for.

    When you change the children of a container node, the container will generally need to receive some information causing it to update. It appears changing the pivot doesn't trigger the container update, but re-assigning the position or size of  one of the buttons  instead of creating a tween should trigger the container update.