Hey! For various tasks, I need to check if a point is contained within a rectangular region (defined by two points)
function IsInRegion(Pos,A,B)
return (Pos.X < math.max(A.X,B.X) and Pos.X > math.min(A.X,B.X)) and (Pos.Y < math.max(A.Y,B.Y) and Pos.Y > math.min(A.Y,B.Y)) and (Pos.Z < math.max(A.Z,B.Z) and Pos.Z > math.min(A.Z,B.Z))
end
Here is my code - but unfortunately, it seems to have some sort of logical flaw which I’m unable to mitigate. Is there any pre-built system that might work, or in-engine solution?
So far I’ve tried:
- AxisAngle’s Rotatable Region3 Module (broke really painfully and had a strange API that wasn’t suitable)
- Region3s (these don’t work as I don’t need to check if a part is in the region, but if a Vector point is)
Thanks!