# Can HBoxContainer Elements Be Arranged in a Curve?

4.3

### Question

Hello everyone,

I’m relatively new to the forum but have been working with Godot for a while. I’m currently working on a project where I need to arrange elements in an HBoxContainer along a curved path rather than in a straight line. Is this possible in Godot? If so, could someone guide me on how to achieve this or suggest any alternative approaches?

Can you provide an example on how its supposed to look?

1 Like

something like this:

You could do this with VBoxContainer’s inside of HBoxContainer and then put a Control Node with the correct size to align them in a curve shape

I was thinking the same thing too, but I want the element to also change its rotation along the curve tangent.

Then you could just rotate it according to its position

I dont think you could do that once you put it under hbox. the layout is locked under the parent

In code it should still work

It is too cumbersome to solve this using an HBox. I decided to code the positions instead. I’m bad at math, but somehow I managed to get it right.

``````extends Control
var central_angle: float = 120.0
var start_position: Vector2 = Vector2(250,1500)
var gap_between_element: float = 20.0

arrange_elements(\$elementNode)

func arrange_elements(n : Control):
# Calculate the angular step
var our_child_count = n.get_child_count()
var step_angle = deg_to_rad(central_angle) / (our_child_count - 1)

# Position each element
for i in range(our_child_count):
var angle = -deg_to_rad(central_angle) / 2 + i * step_angle
var x = start_position.x + i * gap_between_element + radius * sin(angle)
var y = start_position.y + radius * -cos(angle)

var element = n.get_child(i)
element.position = Vector2(x, y)

# Rotate the element to face upward along the curve
element.rotation = angle

``````
3 Likes

Hope the Godot developers can introduce a ‘Curve’ feature in the container.

Shaders might be able to do that actually, but gui-input wont work that way

I was actually looking for this exact thing so that I could make a fanned out hand of cards. Thanks for working out this solution!

Was there anything specific that you had to read or watch to come up with this solution? Im always interested in learning more.