An Area3D reports other areas only through area_entered, and bodies only through body_entered. In our Godot 4.7 test a hurtbox connected to body_entered caught a bolt that was an Area3D 0 times, and caught it once with area_entered. The other common cause is the mask: collision_mask = 3 in code means layers 1 and 2, because the number is bits, so a bolt on layer 3 was missed. set_collision_mask_value(3, true) turns on layer 3 itself. The script below names the reason for any pair.
The code
Save it as hit_check.gd and call it once while you debug, from the hurtbox or from anywhere that has both nodes: for why in preload("res://hit_check.gd").why_not(hurtbox, bullet): print(why). Each line is one reason the hurtbox will not report the bullet. No lines means it will.
extends RefCounted
## Says why an Area3D does not report another area or body, or that it should.
## Call it once while you debug, for example from your hurtbox's _ready():
## for why in HitCheck.why_not(self, bullet): print(why)
## An empty list means the two can see each other.
static func why_not(watcher: Area3D, other: CollisionObject3D) -> PackedStringArray:
var out := PackedStringArray()
if not watcher.monitoring:
out.append("%s has Monitoring off, so it reports nothing" % watcher.name)
if other is Area3D and other.get("monitorable") == false:
out.append("%s has Monitorable off, so other areas cannot see it" % other.name)
if (watcher.collision_mask & other.collision_layer) == 0:
out.append("%s's mask (%s) has none of %s's layers (%s)" % [watcher.name, layers(watcher.collision_mask), other.name, layers(other.collision_layer)])
for n in [watcher, other]:
if not has_shape(n):
out.append("%s has no enabled CollisionShape3D with a shape" % n.name)
var wanted := "area_entered" if other is Area3D else "body_entered"
if watcher.get_signal_connection_list(wanted).is_empty():
out.append("%s is a%s, so it shows up in %s, and nothing is connected to that" % [other.name, "n Area3D" if other is Area3D else " body", wanted])
return out
static func layers(bits: int) -> String: # 5 -> "layers 1, 3"
var l := PackedStringArray()
for i in 32:
if bits & (1 << i):
l.append(str(i + 1))
if l.is_empty():
return "no layers"
return ("layer " if l.size() == 1 else "layers ") + ", ".join(l)
static func has_shape(n: Node) -> bool:
for c in n.get_children():
if c is CollisionShape3D and c.shape != null and not c.disabled:
return true
return false
What we measured
A hurtbox, an Area3D with a 1 m sphere, and a bolt with a 0.2 m sphere placed inside it. Each line gives what the hurtbox reported and what the check printed. Two runs gave the same results.
- Bolt as an Area3D, only
body_enteredconnected: 0. The check: nothing is connected to area_entered. - Bolt as an Area3D, defaults,
area_enteredconnected: 1. The check: no reasons. - Bolt with Monitorable off: 0. The bolt itself still saw the hurtbox, because the hurtbox was still monitorable. The check: Monitorable off.
- Bolt on layer 3 (
collision_layer = 4), hurtboxcollision_mask = 3: 0. The check: the mask has layers 1, 2 and the bolt is on layer 3. - The same bolt, hurtbox with
set_collision_mask_value(3, true): 1. The mask became 5, layers 1 and 3. - Bolt with a mask of 0: the hurtbox still saw it, 1, while the bolt saw nothing. Seeing is one way: it is the watcher's mask that counts.
- Hurtbox with Monitoring off: 0. The check: Monitoring off.
- Bolt as a body (AnimatableBody3D):
body_entered1,area_entered0. - Bolt with its CollisionShape3D disabled: 0. The check: no enabled shape.
Why it happens
Areas and bodies are reported by different signals, so the one you connected decides what you hear about. Monitoring is whether an area looks, Monitorable is whether others can see it, and the two are separate switches. In the Inspector the layer boxes are numbered 1 to 32, but in code a layer is a bit: layer 1 is 1, layer 2 is 2, layer 3 is 4 and layer 4 is 8. So 3 is layers 1 and 2 together. Only the watcher's mask matters for what it reports, which is why a bullet can hit a hurtbox that the bullet itself cannot see.
What to change
- Set layers in code with
set_collision_layer_value(n, true)andset_collision_mask_value(n, true), which take the number the Inspector shows. - A fast bolt that skips past a thin hurtbox between frames: a ray each frame. One hit per swing instead of one per frame: a sword hitbox. Damage while standing inside: a damage zone.
Ready-made bolts: Projectile & Cast VFX for Godot 4 has 41 spell projectiles with their cast, flight and hit. With hit_area on, each bolt carries an Area3D your hurtboxes catch with area_entered, and with hit_body a small body they catch with body_entered, both in the group pd_projectile, and hit_mask and hit_layer take the same bit values described above.
Tested in Godot 4.7 with the Compatibility renderer.
Ready-made: Projectile & Cast VFX for Godot 4 has 41 spell projectiles that can carry an Area3D or a small body for your hurtboxes to catch, on the layer you choose.
More how-tos for Projectile & Cast VFX for Godot 4: Spawn a hit effect facing the surface
More how-tos: Projectiles and aiming
- A ball that hits the net however hard it is kicked
- A shot that meets a moving target
- A fire rate that holds at any frame rate
- Point swords, projectiles and models that face +Z at the target
- FPS shots that land on the crosshair
- A spell that keeps flying straight after it leaves the hand
- Turn towards a target the short way round
- A laser beam that stops where it hits, the moment you aim
- Fast projectiles that never fly through enemies
- A trajectory line that matches where the ball lands
- Aim a spell at the mouse on a 3D floor
- A homing missile that turns, but not instantly
- Particles fall sideways when you rotate the emitter
- Particles that fly into the player
- Gaps in the trail of a fast emitter
- Make a tower shoot the enemy closest to your base
- Hit the target with an arcing shot at any angle and height
- Kick a RigidBody3D ball with the same strength at any tick rate
- Reload without losing or making up rounds
- Fan out any number of projectiles evenly around the aim direction
- Recoil that settles back to where the player aims