Issues with raycast2d and tilemaps

Godot Version

Godot Engine v4.4.1.stable.steam

Question

I’m trying to make a platformer that uses a tilemap for many elements and features an enemy with a raycaster attached. I am having an issue where the raycaster won’t detect the tilemap even tho the collision has been set up properly (I thnk, the mask and layers are the same as some bodies that the raycaster CAN detect). Is there something you have to do to get raycasters to detect tilemaps?

No, it should detect it as long as the layers/masks are correctly set up and RayCast2D.collide_with_bodies is enabled (it’s by default). Try posting some screenshots and code.


hopefully these screenshots help. sorry I can’t provide more I’m in a bit of a rush here today. I can send more if you want. you’ll notice that the tilemap and the raycast have the same layers but the raycast won’t turn red in preview. sorry if this isn’t helpful I’m new to this engine and also game dev.


the preview (have to do these as seperate posts because im new)


the platform tilemaps

gets even weirder because when I put in just a raycast2d with no parent object and had it collide with the tileset it was able to detect it.

FINAL UPDATE FROM ME FOR TONIGHT: after more experimenting it seems like setting the raycast to be too long causes it to break when dealing with tilesets. Further investigation required.