The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+2 votes

According to the documentation:

  • void set_trigger ( bool enable )

Set whether this shape is a trigger. A trigger shape detects
, but is otherwise unaffected by physics (i.e. will not
block movement of colliding objects).

but it doesn't detects collisions at all. A bug?

I want to stop the body when it hits first time the floor but it doesn't collide at all because it is set as trigger.
Any help is welcome.

extends KinematicBody2D

const GRAVITY = 200.0 
var velocity = Vector2()
var gravity
var first_time=true

func _ready():

func _fixed_process(delta):
    var force = Vector2(0, gravity)
    velocity += force*delta
    var motion = velocity*delta

    motion = move(motion)

        var n=get_collision_normal()

        if first_time:
in Engine by (659 points)

Then don't set it as trigger.

1 Answer

0 votes

Take a look at this piece of documentation:
In case of KinematicBody vs StaticBody collision, no one receives the information about the collision.
If you are using body as a trigger, then I would suggest to use Area node instead, if you connect signal body_enter from Area node you will still receive the information about collision with StaticBody. You can put this Area as a child of your KinematicBody, or convert Kinematic to Area (it's your call, both will work)

by (1,299 points)

Every time I read that documentation you point in your link I get more confused.

Reading that table, how it is possible that two KinematicBody2D doesn't report collision information to each other? What's the use of KinematicBody2D.iscolliding() method then?
If I can detect collision information from both KinematicBody2D using the is
colliding() method, why I can't detect it again when the shape is set to trigger?

Either the documentation is wrong or there is a bug.

@genete, I'm unable to answer those question, When I started with Godot (v1.0) this table was accurate and everything was working like it said. Since now you are telling me that 2 KinematicBodies can get info about colliding each other it seems that docs are outdated. When it comes to trigger... I'm unsure as well, since from the time Area nodes have those handy signals I was not using trigger shapes...
From practical point of view I'm suggesting to try Area, when it comes to the questions itself - maybe someone else will have better answers (or suggestions). Sorry for that!

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 Frequently asked questions and 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 [email protected] with your username.