How can I make some objects not appear on top of others in an item list?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By javi98lab

Hello!

I am doing my first project in Godot, and I have a little problem.
I have some objects that randomly come out of an ItemList, and are placed on a ribbon (it’s a sprite)

And I want that when these objects are generated randomly, they cannot come out on top of each other, and others either that when I move them, they can not move on top of others

My idea was to add a rigidbody and a collision shape to the item list, but I see that I am incorrect.

What can I do to fix that they don’t appear on top of each other? Thanks

:bust_in_silhouette: Reply From: dethland

The YSort node can help you. You can add the items you spawn as children of this node. It will automatically place them based on their Y-axis value.

I thought I haven’t explained it correctly.

I have many items, generated by an item list, shown in a small part of the screen. These are generated randomly on the map, and I want to, when they appeared on the screen, can`t be one on top of the other.

In the example you send me, the trees are created by the author, and aren´t created randomly like I`m requesting

Thanks for the answer anyways

Greetings to you

javi98lab | 2021-08-19 06:25

Maybe you can try to spawn an area2d node first to detect whether there is an item. If the signal returns the item, then skip this position and random another one.

dethland | 2021-08-19 06:35