Advertisement
CloneTrooper1019

[Roblox] IsInSpotLight

Mar 21st, 2015
574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.42 KB | None | 0 0
  1. function isInSpotLight(spotLight,position)
  2.     local cone = math.rad(spotLight.Angle)
  3.     local part = spotLight.Parent
  4.     local direction = CFrame.new(part.Position, (part.CFrame * CFrame.new(Vector3.FromNormalId(spotLight.Face))).p)
  5.     local space = direction:pointToObjectSpace(position)
  6.     local unit = space.unit
  7.     return (unit.Z < 0) and (unit.X > (cone/-2) and unit.X < (cone/2)) and (space.magnitude <= spotLight.Range)
  8. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement