Hello everyone,

Each vehicles has two radars: one to detect and move to the target, one to the turret (stop and fire).

When the firsts targets are "destroyed", i want the nexts targets are set up as the new targets. But, when the firsts targets are freed, theirs "area exited" signals still active, but i don't want that.

I have multiple error with get_overlapping_areas(), because "overlapping bodies monitoring are off". This is because i have disabled the shape (in the center of the onwer) who is detected by the radar when the shape's owner is destroyed, i do that to remove it from the detection.

I don't find a way to solve this...

func _on_radarChassis_area_exited(area):
	if cheminUnit.empty() and area.get_overlapping_areas().size() != 0:
		var itemList = []
		var listDist = []
		
		for item in area.get_overlapping_areas():
			if item.get_parent().is_in_group('unitGrp') and item.get_parent().nationCol != nationCol:
				itemList.append(item.get_parent())
				listDist.append(position.distance_to(item.get_parent().position))
				
		if itemList.size() != 0:
			var minDist = listDist.min()
			
			if position.distance_to(itemList[listDist.find(minDist)].position) <= $radarChassis/perimChassis.shape.radius:
				
				set_physics_process(false)
				targetUnit = itemList[listDist.find(minDist)]
				
				move(targetUnit.position)
  • Erich_L

    The target still valid

    I have find another way:

    When the vehicles will be totally freed, the area exited signal of the others is emitted, so i need to check who is dead or not here: Instead of disabling the monitoring/monitorable of the dead vehicles (what give me the error), filtering by the life value solve this, and the cycle can run again until target is in the perimeter.

What if you checked if that target is still a valid instance before you acted on the "area exited" signal?

    Erich_L

    The target still valid

    I have find another way:

    When the vehicles will be totally freed, the area exited signal of the others is emitted, so i need to check who is dead or not here: Instead of disabling the monitoring/monitorable of the dead vehicles (what give me the error), filtering by the life value solve this, and the cycle can run again until target is in the perimeter.