0 votes

I have the tree as:

- gameLevel
-- HUD

This is the code:

func drawLifeIndicators():
    var containerBox = get_node("HUD/HBoxContainer")
    var scene = load("res://batMini.tscn")
    var newBatMini
    for i in range(0, globals.lives):
        newBatMini = scene.instance()
        print("adding mini")

If I check the inspector, yes, all 3 (in this case) life indicators show up as direct children of the HBoxContainer, BUT they all appear to be showing up in the same physical place. Can anyone see why they're being generated in the same position?

in Engine by (830 points)
edited by

What node types are your "life indicators"? If they are not Control-based (ie a 'green' node), they won't align themselves within a container.

Yes you were correct. I changed it to a control base and it NEARLY worked. Then by adding volzhs's answer to the solution it all came together. Thanks for the help.

2 Answers

+2 votes
Best answer

I guess root node of batMini.tscn is just Control node.
try to set min size of it in batMini.tscn
or set it with code newBatMini.set_custom_minimum_size(Vector2(width, height))

by (9,776 points)
selected by

Thank you, with a combination of your answer and YeOldeDM's answer it worked. Much appreciated.

0 votes

I have a similar problem but I could not solve it in code. But if you do it manually select 'Size Flags' -> 'Horizontal': 'Expand'. You will see that it is arranged in order.

by (45 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.