← Pixel Dreamer Studio

Who is inside an AoE attack circle

Measure the distance flat on the ground, then check height separately.

Compare the distance on the ground, x and z only, with the circle's radius, and check height on its own. distance_to() includes height: in our Godot 4.7 test a character 2.9 m from the centre of a 3 m circle, with its origin 1 m above the ground, was 3.07 m away by distance_to() and counted as outside. Of three targets standing inside the circle, distance_to() found 1 and the script below found all 3.

The code

Put this node at the centre of your telegraph circle, on the ground, with radius set to the size the player sees. Add your enemies or players to the hittable group and call targets_hit() at the moment the attack lands.

extends Node3D
## Finds who is inside a round attack warning on the ground, measured flat on the ground.
## Put this at the centre of your telegraph circle and call targets_hit() at the moment the attack lands.

@export var radius := 3.0  ## the same radius as the circle the player sees
@export var group := "hittable"
@export var max_height := 3.0  ## ignore targets further than this above or below the circle


func is_inside(p: Vector3) -> bool:
	var flat := Vector2(p.x - global_position.x, p.z - global_position.z)  # height is left out
	return flat.length() <= radius and absf(p.y - global_position.y) <= max_height


func targets_hit() -> Array[Node3D]:
	var out: Array[Node3D] = []
	for n in get_tree().get_nodes_in_group(group):
		var t := n as Node3D
		if t and is_inside(t.global_position):
			out.append(t)
	return out

What we measured

A circle with a 3 m radius on the ground at the origin.

Two runs gave the same numbers.

Why distance_to misses people standing in the circle

The circle the player sees is flat on the ground, but a character's origin is usually in its body, often a metre or more up. distance_to() measures the straight line in 3D, so the height adds to the distance and pushes characters near the edge, and tall ones, outside a circle they are clearly standing in. Leaving height out matches what the player sees. The separate height check keeps a flyer high above the circle, or someone on the floor above, from being hit.

What to change

Ready-made telegraphs: AoE Telegraphs for Godot 4 has 35 attack warning indicators for boss fights, MOBAs and action RPGs: circles, a meteor target, donuts, cones, skillshot lines, crosses and a checker floor. They fill up and send a triggered signal at the exact moment to apply damage. Flat meshes, not decals, so they work in Compatibility and web exports.

Tested in Godot 4.7 with the Compatibility renderer.

Ready-made: AoE Telegraphs for Godot 4 has 35 ready-made attack warning indicators for boss fights, MOBAs and action RPGs, with a triggered signal at the exact moment to apply damage.

More how-tos for AoE Telegraphs for Godot 4: Particle ring standing up instead of flat

More how-tos: Hazards, traps and attacks