0 votes

Im trying to make object that shoots objects and when it hits a player object, it should disappear.
I want to make the bullet disappear when ever it hits something, but the problem is, if i make it to recognise Area2D and disappear, it works, but at the same time, it doesnt do that for collisionshape2d.. and when i add: ifiscolliding():queuefree() .... but then, Area2D doesnt get signal (and i got attached code for area2d, that when obj enters area, subtract HP..) also, if i use enterbody signal, instead of enterarea, the bullet obj disappears when created. (im also using separate scenes in one scene.)
So, how you can add exception for self in area
body or maybe you have an easy project that has simple shooting, receiving damage project to share..?
I hope you understand what i meant,lol

in Engine by (227 points)

I usually make the object detecting collision call a function on the other, so they both know what happened and only one needs to monitor collisions. But that's my way^^

In the official 2D platformer demo, the character is able to shoot enemies with bullets. Maybe you can have a look at it?

Im trying to do that, but it doesnt work, also i cant a make a area to detect collission from another scene (object like an enemy) groups dont work across the scenes too : /
I have looked at those, but that is in Rigidbody and that whole code is just too complex for me (im rly a beginner) all those extend and such, i dont know those and those tutorials just dont seem to make any sense to me : /

The shooter demo could be the most simple one to look at.

Groups should work between scenes, maybe you need to update or re-add the instanced scenes if you added the groups later.

1 Answer

0 votes

I'm not sure I understood it* but you can just use:

func body_enter(body):
   if body == self:


*You NEED to use code sample "is_colliding()", otherwise everything is emphasized, because someone thought making _ the symbol for that was a good idea.

by (1,124 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 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.