Hello,
This time, I get no way to access a simple button in GDScript:

I have tried with $'HUD/blue', $HUD/blue, and with 'access with unique name' as $'%blue' or %blue or $%blue, none works.
The word completion even suggests me them.
Porting to godot 4 is not seamless...

  • Toxe and xyz replied to this.
  • moonmoon27 In what function are you trying to call this? Is it something that runs before _ready()? Because in that case chances are that your child nodes aren't ready yet and still null.

    And I just notice that in your method list you have an _init() method. Are you calling this from _init()? In that case it cannot work because your child nodes aren't ready yet.

    moonmoon27 Simply drag your button into your code and Godot will give you the best way to access it. In this case it would be %blue. $HUD/blue would also work.

    Hi Toxe,
    Sorry, but both do not work. By the way, I don't understand why dragging would have another effect than just typing it.
    I should have another issue there, because it was working 2 days ago....
    Thanks anyway

    • Toxe replied to this.

      moonmoon27 I have tried with $'HUD/blue', $HUD/blue, and with 'access with unique name' as $'%blue' or %blue or $%blue, none works.

      Are you sure %blue.set_pressed(true) is not working?

      moonmoon27 By the way, I don't understand why dragging would have another effect than just typing it.

      Just to be certain because if you drag the node then the editor will give you the full path that is working.

      Can you upload this project here or a stripped-down version that shows the problem? Unless your Main.gd script is not attached to your Main node I don't see why this shouldn't work.

      moonmoon27 In what function are you trying to call this? Is it something that runs before _ready()? Because in that case chances are that your child nodes aren't ready yet and still null.

      And I just notice that in your method list you have an _init() method. Are you calling this from _init()? In that case it cannot work because your child nodes aren't ready yet.

      You find it! I called it in _init() method, I have placed this line in _ready(), do not crash anymore and checked the button.
      Many thanks to you both