How to spawn NPC's in dark?

Hi there! I would like to know how to spawn NPC’s in dark, so for example if i put light in some place, NPC’s will spawn anywhere, except for lighted spot. Kind of like in Minecraft

1 Like

Not 100% sure just thinking about it right now, would there be any way you could like check the distance of the light to where the spawner is or if it’s random check if where it is gonna spawn if there is a light near it via distance.

I don’t know what you could use for this, parts or rays or whatever else there is? Code ?

Sure

ineed30symbolslolololll123123

Try using overlap params

char limit

I’d do it by looping through different spots in the map, running a function that checks whether the spot is in darkness by raycasting to all lights in the map as well as straight up (to check whether it is in sunlight). If the spot is in range of any light, or is lit up by global illumination, spawn the NPC

You could use either the Dot Product method [ to get the angle etc], magnitude or even raycasting.

Try out this resource:

This could help you.