I am using 4.2
So I’m working on a scene that has an array of Area2Ds to detect areas and bodies to place down new ones in unfilled spaces.
The issue I’m having is when creating a new StaticBody2D the areas don’t detect it. The areas are able to detect the same scene only when it’s placed there from the scene editor.
Just as a note, I’ve checked the collision layers and they are correct.
Interestingly enough, it completely works with Area2Ds. The issue with my code is just detecting the StaticBody2D
Here’s my code:
Script
for x in buy_array:
Y coords
for y in x:
var y = get_node(y)
if len(y.get_overlapping_areas()) == 0 and len(y.get_overlapping_bodies()) == 0:
var BODY = _BODY.instantiate()
BODY.ammo = 30
BODY.modulate = "ff6b6b"
BODY.position = position + y.position + Vector2(35, 35)
get_tree().current_scene.add_child(BODY)
break
Thank you!