Enemy not killing player - Godot 3 to godot 4

Hi! I’m using this video, which I believe is in Godot 3, to make the shooting/killing mechanic for my game in Godot 4: https://www.youtube.com/watch?v=5vYI_mgERBU. I am a very beginner so I needed a perfect tutorial and this had all the things I wanted, but I’m getting an error and I don’t know whether I just typed the code wrong or it’s something different in Godot 4. The sticks are supposed to get rid of the heart (player) when they touch the player, but they just gather around it weirdly.
Does anyone know how to fix this? Thanks!!



Is there any error code ? :face_with_monocle:

If yes, paste the error code in here, so that others can help you.

If no, maybe the problem is in your collision setting, for example the player/enemy may have a wrong collision layer or something.

P.S. I am not sure, I can’t see any info of collision setting in your question…

There is no error code.
I changed the collision settings but it still acts weird - the sticks do not kill the heart (which would make game reset), which they are supposed to do.
Here are screenshots of my collision settings:


Disregard this stick screenshot, I actually changed it back to layer 1 mask 1

Oh…how do I said that…

In your case, you use enemy’s subnode RayCast2D to detect and kill player.
So the problem is the collision between player and enemy’s subnode raycast.
Not the collision between player and enemy. It’s different.

Mayby you can take a look of this video, it show the different between collision masks and layers.

Thank you for all of your help! So I checked collision for raycasts and fixed anything that needed to be fixed but it didn’t do anything.
I then realized that the name of the heart was messed up so I fixed that so the sticks should correctly identify the heart and kill it. But now it just keeps glitching like this and it won’t allow me to move the heart:

In fact, I’m not sure what you done, there are lots reasons could cause bug happen …

Maybe, you have to know how to debug by yourself at first, or it might cause more bug when you try to fix.

Search “Godot debug” in youtube, and pick one video to learn.

Okay, I’ll try that, thank you!

You already tried to run the game with visible collisions shapes enabled? With that you can see if your raycast are targeting the player correctly

image


Also, you’re doing the ray check and the moviments in the _process callback which is a terrible idea, everything physics related should be done inside _physics_process callback