0 votes

I know, this seems like a pretty easy question, but the more I think about it, the more weird it gets for me to understand. In my code, I iterate some times, and with each iteration I want to place a scene next to the previous one (if there is a previous one, of course). I want to be able to place this scene sometimes on top/at the bottom/to the right/to the left bounds of the previous one, so that they do not get overlapped, like a TileMap, but with scenes instead of tiles. Is there a way to do this with a Node2D, or will I be forced to use some other type of node like a TileMap or even a RigidBody?

Godot version 3.3.2
in Engine by (97 points)

1 Answer

0 votes

Just have a variable that represents the size of the scene and then add that size to the position of the next scene so that they don't overlap.

by (7,338 points)

I thought about that, but what if I do not know the size? Can I get it from the node?

No, Node2D doesn't have a "size" property. It really depends on what "size" means. Is it the sprite size? Then you can use the width and height of the sprite.

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 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 webmaster@godotengine.org with your username.