0 votes

So, I've been making some progress on my first project, but just hit a roadblock that I haven't been able to figure out so far.

I have the _ready function of my main scene ("Level") set up so that it'll instance and add to the scene a certain number of Area2D scenes that belong to the group "pieces". Said "pieces" each have 3 child nodes that are also Area2Ds - albeit on different layers - and belong to the group "sides". As far as I've been able to test it, all the grouping stuff seems to be working just fine.

The "pieces" are added to the scene in the correct positions, and some of the "sides" overlap as intended. However, calling getoverlappingsides() on each "side" returns an empty list. This only happens during this initial setup, and the function seems to work just fine in other situations when it's called during actual gameplay.

Does this have something to do with the specifics of how scenes enter the tree? Should I use call_deferred() or something? I'm a beginner and still haven't managed to wrap my head around how that works.

in Engine by (24 points)

1 Answer

0 votes

The function get_overlapping_areas() is related to the physics properties of the engine. Specifically, it utilizes a CollisionObject2D to calculate how physics and collisions are handled. Since the physics server can use a bunch of threads and processes, it is recommended to use the _physics_process() callback for your collision needs.

by (1,988 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 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.