How To Make A Flashlight In 3D Space

How do I…

How do I make a flashlight in a 3D scene like “Night Shift”, Im making a horror game in 3D and to make it scary I made the scene very dark and the player will need a flashlight, I got the inspiration to make a horror game from the game Night Shift on gd.games, but I have no clue how they made the flashlight in their game work. Heres the link to the game, NIGHT SHIFT | Play on gd.games

What is the expected result

I want to be able to have a toggleable flashlight that lights up the surrounding area.

What is the actual result

There is no result because everything I tried didn’t work.

I know this is an old post, but this might help someone in the future.

I found a simple way to make a flashlight in 3D using raycasting.

I created one cube that will be raycasted, set it in the events to follow the camera’s center (X, Y, Z), and made it hidden so it doesn’t appear in the scene. and gave it inverted normals so the raycast works properly from the inside.

This way, the raycast is always hitting that cube, no matter where the player looks even at the sky.