0 votes

my bullet is an area 2d node with it's own scene. It is being instanced in my main scene, which has a kinematic body 2d with a collision shape 2d that i want to detect the collision with. All the collision tutorials i see, have used areas and signals. The problem is, I'm not using an area (except in the bullet, which isn't the node i want to detect with,) and that the bullet is only instanced, so it's hard to connect the signal with it. How do i do this?

in Engine by (391 points)

1 Answer

+1 vote
Best answer

I'd suggest adding hitboxes to your kinematic body 2d, and by hitboxes I really mean an Area2D node. Then connect your hitboxes' body_entered signals to your KinematicBody2D's script.

Using areas is the preferred way to do collision detection.

by (1,254 points)
selected by

ok, so it's common to have an area 2d node along with a kinematic body 2d?

ok, so i did what you said, but the kinematic body isn't detecting my bullet. It's totally ignoring it. I connected the kinematic body 2d's area 2d nodes area_entered() signal to the kinematic body 2d, and none of the code i've written under the signal code is working. any ideas?

Yup. The only collision detection that KinematicBody exposes is in the move_and_collide function. Although those collisions are intended to be used for movement logic.

Separating the physics collisions (movement, forces) from the gameplay collisions (area triggers, custom logic) is good practice as well.

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.