How can I make an actor react to light?

I want it so that if an actor gets hit by a specific light the actor slowly loses health. How would I go about doing it? Should I use light channels or raycasts?

The easiest way is probably to create a collision sphere for point lights. As long as the actor is overlapping the sphere, he gets damage.
For spot lights it is a bit trickier because there is no collision primitive representing a cone. Still, you could just use an approximated convex cone collision. For example the cone mesh that is included in the engine and scale it to fit your spotlight (might be easier to create a cone with a better pivot though).

Ofc, you could also use raycasts. For point lights, it would be “SphereTrace by channel”. For cones, you probably have to do multiple raycasts to get an accurate result if your light radius is big.

Raycasts are relatively cheap. Collisions can add up more. Generally, they aren’t really considered expensive but as always, this depends on what platform you’re targeting and the overall complexity of your game.
If you only have one sun object you can ofc trace in that direction and see if something blocks the way. Depending on your character this might be a bit inaccurate if you really care about if a body part is getting hit by light (assuming you have a character with some limbs :D).

If there are visible shadows and you should only stand in those, you could make collision overlaps for those areas.
Can’t really say what’s best because I don’t know your game :stuck_out_tongue: But if you only have one huge lightsource, raytraces seem to be the nicest way to solve it.

But what if I planned to add a raycast to a sun object really high up? And don’t raycats impact performance considerably?

Well then thanks bro! As for the game I’m trying to add vampires in it.

That’s what I guessed :smiley:
Np!