Shadow Detection

Hello.

If you have ever played Silhoutte you would know that the whole game is about staying in the shadow because the sun is deadly.

I want to replicate this kind of mechanic, although I am unsure of how I will be able to do that.

I’m not asking for a script or anything (unless u want to lol), just want to know how to do this mechanic.

I’m just guessing (and I could be completely wrong), but it may be done with raycasting.

Theoretically, every heartbeat, you can raycast from the position of the sun toward the player. Then, if the raycast doesn’t hit the player, then it means they are in a shadow. (You can do this for every part in the players body for more accuracy ig)

2 Likes

But how would you detect a shadow? I’m not an expert on Raycasting but I’m pretty sure you can’t do that.

I will try this. Hopefully it will work, also how would I Raycast from the sun?

You can try using this:

local SunDirection = game.Lighting:GetSunDirection() --> Returns a Vector3 direction of where the sun is pointing from 0,0,0

Someone created a module that ‘shadow casts’ that I think could also be helpful.

2 Likes

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