How to detect if two 3D characters are intersecting without collisions?

Godot Version

Godot 4.2.2

Question

I have a player object and a monster object. I want the monster to be completely intangible, but I want it to be able to hurt the player. How can I detect if the player and monster are intersecting?

You use an area node (Area2D or Area3D) for the monster. Area nodes can detect overlapping physics bodies, but they don’t otherwise interact with them, so the monster will still be intangible.

1 Like

As far as I know you will need a collision shape of some sort, however, my experience is with 2D.

In the the code for the monster you would have something like:

func _on_body_entered2d(body):
    if body.name == "player":
           #do some damage
           player.health(-10)

Except you would use the 3D version of that. There is also an overlapping bodies function you can use in which case you would use a for loop to go through the bodies to find the player then do the damage.

And don’t have any code like that in the player, that way only the monster can do damage.

HTH.

1 Like