Area3D Overlap Detection Using C#

Godot Version

4.7.1

Question

Hi, all!

Let me know if I’m asking this in the wrong place! Using C#, beginner using Godot.

Basic issue: Two actors/scenes, both have Area3D as root node type. I just need an overlap to trigger. It’s an ammo_base scene (from a defense turret) and enemy_base scene, I’m simply trying to shoot the enemy and detect the overlap. (Turret fires bullet, bullet overlaps with enemy)

Both actors/scenes have a collision shape large enough to overlap. Ammo has layer 10 (enemy layer) and mask 11 (The ammo itself). Enemy has layer 11 (ammo) and mask 10 (the enemy itself).

Since I am using C#, I set up my overlap using _ready (AreaEntered += OnAreaEntered;) to create my own signal. Then a simple “private void OnAreaEntered(Area3D area)” function to GD.Print something when it overlaps. But no overlap ever happens.

This is a turret defense learning project I’m trying (I come from Unreal) to help learn Godot. I spawn my enemies using a timer by adding a PathFollow3D, then an enemy_base.

So here is my actual question: Is my concept correct, since overlaps never detect?

I’m having a really tough time understanding how Godot handles overlaps. It seems so simple, but in practice this has turned into a nightmare. I get multiple errors complaining about my defense turret not being the correct class, even though that scene is on mask and layer 1. This is probably as the bullet leaves the defense turret, but why does it overlap? Very frustrating.

I’m not asking anyone to fix my entire project, just looking for a bit of direction. And to start actively engaging with other developers.

Thanks for your time reading this!

The area_entered signal is the correct way to detect overlapping areas. Caveats:

  • Collision layer/mask must match.
  • Mixing 2D and 3D collision nodes does not work.
  • In 3D, the areas actually need to overlap in 3D space.
  • The areas need to have actual collision shapes.
  • The monitoring and monitorable properties need to be correctly set.
  • Overlapping areas that spawn overlapped and do not move may not be detected.
  • ConcavePolygonShape3D may fail to work.
  • If you’re not moving the Area3D nodes directly but their parent node, make sure that there are no non-3D nodes in the node tree between the Areas3D and the node you’re moving.

That sounds worth investigating further, but you haven’t given nearly enough information to diagnose it. What’s the exact error message? Can you post the function where the error triggers?

Thank you for the guidance, I appreciate it more than you know!

  • Collision layer/masks match
  • Only using 3D Collision
  • The areas do overlap in 3D space. I even put the bullet in the road at the correct height so the enemy drives through it, but no trigger.
  • Areas have collision shapes, basic block.
  • Monitoring and Monitorable ticks are ticked.
  • The spawn outside of overlaps, and move through.
  • Not using concave, just blocks.
  • I’ll check this out. I’m using a PathFollow3D to move the enemy on the road along a spline, so the issue might be here somewhere.

The errors are due to my Defense Turret scene that shoots the bullet. It’s not an Area3D root, so I think the bullet overlaps it when it spawns and throws the error.

I’ll create a new project from scratch with only two objects and test with no parenting, no base classes, no paths. Knowing my concept and using area3D overlap is the way to go, I can do testing with more confidence.

I’ll post feedback as soon as I have it! Thanks again!