SpotLight scripting help

Im trying to script a horror game and when the creature that’s attacking touches light from a spot light it slows down. The light is from the players and lamps.
attafck
I have tried to do a touched command but that wont work.
Is There A Way To Do This?

Thank You,
Sapire

1 Like

try using raycasting

You will need to do it with math. Get the direction of the spotlight, and the unitized difference vector (just a subtraction of one position from the other) of the light’s position, to the position of the monster. If the dot product of those two vectors(the difference and the direction) is less than the angle of your spotlight, then the monster is within the spotlight’s cone of view. You will also need to check that the difference vector’s magnitude is shorter than the max range of the spotlight, to make sure that it can still move, if it’s too far away from the spotlight to be hit, too.