0 votes

I can't make this work! :(

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.

enter image description here


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

enter image description here

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 bodyenter works in process or fixedprocess?
  • Does it work at all on Area instances or only works as RigidBody?

Help me plz, Math

in Engine by (40 points)

1 Answer

0 votes

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

by (16 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.