Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

3D Collision w/ angles?

Asked by 9 years ago

I'm creating a custom 3D collision script Here is what I've got so far, it just doesn't account for angles, and rotation

function CD(x1, y1, z1, w1, h1, l1, x2, y2, z2, w2, h2, l2)
    local x3 = x1 + w1
    local y3 = y1 + h1
    local z3 = z1 + l1
    local x4 = x2 + w2
    local y4 = y2 + h2
    local z4 = z2 + l2
    return x1 < x4 and x3 > x2 and y1 < y4 and y3 > y2 and z1 < z4 and z3 > z2
end
x1,y1,z1,w1,h1,l1 = Obj.X, Obj.Y, Obj.Z, ObjSize.X, ObjSize.Y, ObjSize.Z
x2,y2,z2,w2,h2,l2 = Obj2.X, Obj2.Y, Obj2.Z, Obj2Size.X, Obj2Size.Y, Obj2Size.Z
if CD(x1,y1,z1,w1,h1,l1,x2,y2,z2,w2,h2,l2) then
    Collision = true
else
    Collision = false
end

Answer this question