Hello all! First post, learning the engine for about a month or 2 now, so if I missed another thread explaining this, apologies. I'm having a hard time wording this so I'll just be very specific about what I'm trying to implement. Basically, I'm launching a barrage of mortars, it uses your mouse location to pass position coordinates as a target to land at. I have them going up, turning around, and coming down. They stop at their final destination and explode(via an animated sprite) The problem is they aren't reporting any hits if I wait until the mortar is at it's destination.(I.E. I don't want anything to interrupt it's 'flight' so I have to disable the collision shape until it arrives) I tried using physics bodies and area2d's for this, however it seems that if both objects aren't moving, even when overlapping, they don't register hits with each other. (Maybe I've implemented something wrong, if I can do this with Area2D's that would be fine, I just don't know how to make it only register right when I want it to)

I've already done away with using physics and managed to recreate the movement with it being only a sprite. How would I go about finding if any other collision shapes are within a radius? I thought about using raycasts, but can you even make a raycast just check in a full circle in a reasonable amount of time?

Hopefully I described that well enough lol

Welcome to the forums @"Crusty Slumps"!

If you have an Area2D, you can use get_overlapping_areas (documentation) to get all the Area2D nodes inside of an Area2D at any given time, or get_overlapping_bodies if you want collision bodies.

So, if you have an Area2D for the motor, I would do something like this (untested, example code):

extends Area2D
var exploded = false

func _explode():
	if exploded == true:
		return
	
	# get all the Area2Ds
	var areas_in_motor = get_overlapping_areas()
	for single_area in areas_in_motor:
		# Only damage nodes that have a function called “damage”
		If single_area.has_method(“Damage”):
			single_area.damage()
	
	exploded = true
	# if you want to destroy the motor
	#queue_free()

That should work. I don’t think there is a way to get all nodes within the radius of a position without using some form of physics, or iterating over every node in the scene and checking the distance from a given point.

Oooooffff course it was that simple... lol Thank you very much, I was overthinking this waaayyy too hard aparently.

2 years later