+1 vote

Question
Is there a way in Godot to check whether a certain node or is under shadow or is reached by the light of a light source? I.e, if the leg of the enemy is in shadow, I'd like to hide the whole enemy from view.

Context
I'm working on an isometric game. The viewing angle is such that the player might be hidden behind horizontal walls. I use light occluders placed at the TOP of the walls, and the light sources that are used to illuminate part of the map and mask enemies and objects outside viewing range are put at the head of the player.
I decided to add a little script that, upon entering a room, removes the bottom wall and also moves the light occluder from the top of the wall to the bottom, so once inside the room, the player sees everything.
The problem is, that once the player is in the room, enemies that would be in the room BELOW the current room, might have their head peek over the now-lowered light occluders.

What have I tried
I tried to use raycasting between the player and the enemy, so maybe I can find whether there is a light occluder between the origin of the two nodes, but I got super confused by the workings of the raycast, and found no reference whether it is possible to find intersecting light occluder polygons. It got caught however in the different children nodes (collision shapes) of the enemy or the player, even when I'm adding both of them in the exclude array. Admittedly, I'll have a hard time figuring out raycasting, so I'd like to know if it is even possible to do what I'm trying to achieve here.

Godot version 3.2.3 on Arch Linux
in Engine by (13 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.