Download

Checking if Player is hit by Light

Hello,
I am currently working on a Horror Multiplayer Game and have to program a system that checks if my Enemy is hit by the Spotlight i used as the Players flashlight, because my enem is naturally invisible and can only attack when hes invisible, so if he gets lit by the spotlight he would be turning visible, but i found no way to properly detect if my Enemy character is getting lit or not.

Look into this.

https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseRaycasts/Blueprints/

Also, from the bottom of this page which sounds most applicable to what you’re looking for.

My problem now is that it gets hi, but when i try to cast it to my Monster to get visible, my cast always fails.

You should try to cast from the actor returned in the hit result. Get Player Character returns the playable character (the one you’re controlling) not the monster unless you’re controlling the monster ^^’

ah ok :smiley: i look if it solves my problem

Ok it works ^^ but my monster goes only invisible again if i turn off my FlashLight :smiley: not if i dont tracehit it with an turned on flashlight

you should make a branch in the hit result and check if the hit actor is that monster. If that check returns false then make that monster invisible again.

I did it like this: image_126294.png
But i cant check if i dont hit it, i think because i only equal the hit actor to my monster ^^

I checked it, the “Monster” only goes invisible when hitting it with a TracebyChannel while the light is turned off.