Raycast is colliding with it's parent or a similar invisible node. How do I fix this?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Dadango
:warning: Old Version Published before Godot 3 was released.

So I’m making my first game i Godot engine, and liking it so far. Everything worked, but then i added another “enemy” to the game, and since I have been unable to get it to work. I made a new scene for testing, and I can’t figure out what is wrong.

Script:

2d view of testing scene:

The “error”/the collision:

So as you can see, it collides with… itself?
The collision position (350,450) is the position of the Parent Node:

Everything worked before, but I probably f*cked something up along the way. Any help is very much appreciated

Your rays are not looking at the layer of the body, right?
(check layer on body properties and layer mask on rays, also type of body on rays if needed)

eons | 2016-11-24 20:04

Thank you so much. Last time i tried using Layers and Mask it didn’t work, but now it does. I’ve been pulling out hairs over this for hours, you saved my day :smiley:

Dadango | 2016-11-24 20:43

:bust_in_silhouette: Reply From: Dadango

For now this is fixed, thanks to eons. I’m answering to close it, so other people can get their answers :slight_smile:

Layers and mask could be confusing, especially for the current namings of properties and methods but these may get reviewed on 3.

Basically a (collision) layer is where the object is detected and mask (or mask layer or layer mask or collision mask) is where it monitors for detections.

eons | 2016-11-24 21:00

I know about mask and layer mask, but they Godot engine has it in a very… visual way? with the boxes next to each other and all.
That is just not what i was used to, as it has no hierarchy and more freedom, which I think is better, I just didn’t get it.

But thanks for the explanation anyway and thank you for the help :slight_smile:

Dadango | 2016-11-25 10:24