Get_overlapping_bodies() returns an empty array

Godot Version

4.2.2

Question

When spawning a new CharacterBody3D, the first physics frame doesn’t properly check it’s collision, how can I go around it?

I basically have a projectile spawning into the scene and I want to check if it’s within the bounds of the map, to check it I use the get_overlapping_bodies() function and if it isn’t in the returning array, I delete it.

The problem is that I run the check each frame(or every x number of frames) and in the frame that comes immediately after the spawning of the projectile the array always comes empty(in the next frames it performs at it should) which brakes some of the logic.

How can I solve or avoid the problem? I guess I could avoid checking the first frame but I would rather ask if there’s a more elegant solution first.

Thanks in advance :slight_smile: !

From docs. Could this be a clue?

For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.

Oooh I think that’s it! Thank you so much!

Since I know the ‘issue’ is a consistent one frame behind the fix will be easy :))