Godot Version
v4.4.1
Question
Hi all,
I’m having a problem with raycast collisions I’m hoping someone can help explain to me.
I have some Area2Ds (with CollisionShapes of course) in my world, setting the collision layers and masks, layer 2 for my Apples and layer 3 for my Water sources (right side of screenshot).
I’m generating a bunch of RayCast2D nodes via code (GDScript) and setting the collision masks on the rays with the set_collision_mask()
function (top left of screenshot).
Then I’m checking if the rays have a collision and if the collider has the collision layer, I tried collision masks here to, but that didn’t work at all, maybe I should be checking masks instead of layers, if someone knows the best way? (bottom left of screenshot).
Now for some reason, with the exact same setup and code checks, rays colliding with my Apples (layer and mask 2) work fine, and the sees_food
variable gets set to true (as I expect). But when colliding with water (layer and mask 3) it doesn’t affect the sees_water
variable.
The code, layers and masks for both the raycasts and Area2Ds are all exactly the same… am I going crazy? Does anyone know why it isn’t detecting the Water in collision_layer 3?