Right now im making a no clip check and im needing to check if a position is inside of a part
how would I detect if a position is inside a part
not a part inside another part but some math to check if its inside or not
1 Like
found this, dunno if it helps
function isPointInVolume(point: Vector3, volumeCenter: CFrame, volumeSize: Vector3): boolean
local volumeSpacePoint = volumeCenter:PointToObjectSpace(point)
return volumeSpacePoint.X >= -volumeSize.X/2
and volumeSpacePoint.X <= volumeSize.X/2
and volumeSpacePoint.Y >= -volumeSize.Y/2
and volumeSpacePoint.Y <= volumeSize.Y/2
and volumeSpacePoint.Z >= -volumeSize.Z/2
and volumeSpacePoint.Z <= volumeSize.Z/2
end
function isPointInPart(point: Vector3, part: BasePart): boolean
return isPointInVolume(point, part.CFrame, part.Size)
end
Should work, can’t test it right now. You might want to use >
and <
instead depending on your needs.
7 Likes
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.