body_enter with 3D objects

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MathieuJazz
:warning: Old Version Published before Godot 3 was released.

I can’t make this work! :frowning:

So my goal is to simply detect the other colliders that gets in my trigger.

I modeled a 3D Cone that will act like a “spray” weapon to anyone that stands in it.


The code is located in the root obj of the cone:

So I tried the code as an Area object (PS: the “#” are there to avoid errors in that case):

 extends Area

func _ready():
	#set_contact_monitor(true)
	#set_max_contacts_reported(5)
	connect("body_enter", self, "_on_body_enter")
	pass

func _on_body_enter(body):
	print (body.get_name())
	pass

and as a RigidBody instance (Yes, I changed the root obj type):

extends RigidBody

func _ready():
	set_contact_monitor(true)
	set_max_contacts_reported(5)
	connect("body_enter", self, "_on_body_enter")
	pass

func _on_body_enter(body):
	print (body.get_name())
	pass

In either ways, nothing is printed in the output!!

Are there some important things I am missing?:

  • Do other colliding objects needs a trigger collision shape?
  • Does body_enter works in process or fixed_process?
  • Does it work at all on Area instances or only works as RigidBody?

Help me plz, Math

:bust_in_silhouette: Reply From: wf192

You need an Collision Shape as Child of your Area.
The collision shape has a property, Shape, and there is where you can load your Cone