Raycast2D don't collide with the tilemap

Godot Version

v4.2.2.stable.flathub

Question

I wanted to add a push off the ledges for my platformer using raycast2D but it don’t collide with my tilemap. The collision layers are the same and my raycasts collide with areas and bodies.
I tried some solutions from reddit but it didn’t work :frowning:

The collision_mask from the raycast2d is the same as the collision_layer of the tilemap?

Yes, they’re both on the layer 1

Can you send a screenshot of your scene?

Sure, here they are:

I can’t directly post images as my account here is new

Maybe set exclude_parent = true?

Still not detecting the tilemap :confused:
But I discovered something weird, sometime the raycast says it’s colliding when it shouldn’t (exemple of the “glitch”: 2024-07-23 21-13-46.mp4 - Google Drive)
The bools in the terminal say for each raycast if it’s colliding

Can you call:

raycast.add_exception(self)

for every raycast in your player script? (only if the player is on collision-layer 1)
And make the parent of the raycast a node2d instead of a node maybe. Theres a possibility that, since the “Node” doesnt have a position, it leads to weird interaction with the children position

1 Like

Just changing the parent to a 2d node instead just a node fixed the problem, thanks you so much !

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.