How to detect if the player is in the sun or not?!?

I am trying to make a Vampire game and i am currently new to unreal 4. I want to have it that when your character(Vampire) gos in the sun light(rays in houses as well) you will burn. I know we have source code so can we take the shading from the directional light to detect it?

If anyone is interested in helping with the production of this game please give me an email at ste.gan@hotmail.ca with Work as the subject. I will brief anyone that wants in at that time. Thank you to any help and i will be putting anyone who helps even minor in the credits.

Hi Skullzz098, I’m not sure whether you can detect light directly, but here’s what you could try instead.

Do a line trace from your character (his head, or torso, maybe multiple body parts at the same time) in the direction of the sun. You probably have a directional light representing the sun, just take the angle of that light. So, if you don’t detect any obstacle for a certain length, you can assume that the player is not covered by an object.

If line traces are not enough, you could also try doing a swipe of some more complex shape.

1 Like

Hi Skullzz098,

If the light is not going to be moving, you could simply use pain causing volumes at the points that the light shines. When the player moves into these they take damage (or die). That would be a simplistic approach and would be more difficult if you implement a day/night cylce, however if your game’s lighting will be remaining constant it is a viable option.

I found this

Yeah I’d trace a ray from a point out near the skybox that represents your directional light to a hitbox on the player. It’s sun that kills vampires, not so much torchlight, so that’s an easy solution.