Created
April 29, 2015 10:56
-
-
Save Elmuti/faeacfc1cdb45d1514f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getRayEntranceAndExit(pos, dir, distance) | |
local ignore = deepcopy(_G.ignorelist) | |
local Ray1 = Ray.new(pos, dir.unit*distance) | |
local obj, enter, enterface = workspace:FindPartOnRayWithIgnoreList(Ray1, _G.ignorelist) | |
if obj ~= nil then | |
table.insert(ignore, obj) | |
end | |
local Ray2 = Ray.new(enter, dir.unit*distance) | |
local _, hpos2 = workspace:FindPartOnRayWithIgnoreList(Ray2, ignore) | |
local Ray3 = Ray.new(hpos2, CFrame.new(hpos2, enter).lookVector.unit*distance) | |
local _, exit, exitface = workspace:FindPartOnRayWithIgnoreList(Ray3, _G.ignorelist) | |
return obj, enter, exit, vectorToFace(obj, enterface), vectorToFace(obj, exitface) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
function deepcopy(orig)
local orig_type = type(orig)
local copy
if orig_type == 'table' then
copy = {}
for orig_key, orig_value in next, orig, nil do
copy[deepcopy(orig_key)] = deepcopy(orig_value)
end
setmetatable(copy, deepcopy(getmetatable(orig)))
else -- number, string, boolean, etc
copy = orig
end
return copy
end