Hello,
i have the following Porblem. the player can create some buildings while playing. that for i put a preview on the cursor. this preview has an area2d to detect if its colliding with some solide shapes.
but unfortunately its detecting itself all the time.
i already tryed to use a different layer and a different mask but that dosnt work.
its detecting itself.
func PreShow(): #zeigt das zu Platzierende element an der Maus an
var childCount = get_child_count()
if Globals.placeItem == true:
if childCount == 0:
whatToPlace = MAIS.instance()
whatToPlace.add_to_group("DoNotCollide")
whatToPlace.connect("body_entered",self,"CheckForCollide")
add_child(whatToPlace)
else:
var xy = Globals.transformMousepositionToMap()
var x = xy[0]
var y = xy[1]
whatToPlace.position.x = x
whatToPlace.position.y = y
if prePosition != Vector2(x,y):
CheckForCollide(whatToPlace)
prePosition = Vector2(x,y)
if Globals.willCollideWithSolid:
whatToPlace.modulate.r =3.0
else:
whatToPlace.modulate.r = 1.0
if Globals.placeItem == false and childCount > 0:
for i in get_children():
i.queue_free()
func CheckForCollide(item):
if item:
if item != whatToPlace:
Globals.willCollideWithSolid = true
else:
Globals.willCollideWithSolid = false
print(Globals.willCollideWithSolid)