Raycast no longer detects Area2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Savi

Hello I just started using the Godot engine but i’ve worked with Unity for more than a year so i have a bit of experience with game dev.

I’m making a tile based game where the player checks the surrounding tiles using raycasts. I had a scene called “Door” to make the player go to the next level and it was working as aspected. (It was an area2d with a sprite and collision shape children). The player would check if the rascast was hitting something and if that thing was a Door instance using return obstacle is Door(I’m planning on refactoring this bit in the future to use groups)

The problem started when I decided to create an Interactable scene and then make other scenes inherit from it. This scene its just like the Door scene: An Area2D with a sprite and collision shape. However, the player does not detect any of the scenes that inherit from Interactable (TreasureChest and Portal) as well as the Door!


(The Door is not in this image, that’s the Portal)

There’s and Enemy scene that also checks its raycasts hits for movement and it’s behaving just like the player, ignoring both interactables. It also ignores the player when you are “on top” of the interactable and then you get the player, enemy and interactable in the same spot.

What I have tried so far:

  • Checking if the raycasts where enabled, Collide With Areas checked and tried every combination of collision mask and layer.
  • Removing any tiles that where underneath the TreasureChest/Portal.
  • Changing size of the areas and raycasts.

The whole project can be found here:
https://github.com/SaviHex/ShellDungeon

Thank you so much for taking the time to read my giant question!

:bust_in_silhouette: Reply From: Savi

Found the solution!
The problem was that I was changing the collision layer on the scene file (ie. TreasureChest.tscn) but those changes were not updating the instanced nodes on the main scene.