Start typing to search packages!
SpatialUtils
Utilities for checking whether a position is inside various shapes and node defined regions.
Usage
local SpatialUtils = require(path.to.SpatialUtils)
if SpatialUtils:IsPositionInPart(character.PrimaryPart.Position, zonePart) then
-- position is inside the part
end
local inRegion = SpatialUtils:IsPositionInRegion(position, {
Vector3.new(0, 0, 0),
Vector3.new(100, 0, 0),
Vector3.new(100, 0, 100),
Vector3.new(0, 0, 100)
})
API
SpatialUtils:IsPositionInSphere(position, origin, size)
Checks the position against a sphere at the origin. size is the diameter, matching a ball part's size.
SpatialUtils:IsPositionInBox(position, origin, size)
Checks the position against a box at the origin with the given size, respecting the origin's rotation.
SpatialUtils:IsPositionInCylinder(position, origin, size)
Checks the position against a cylinder at the origin. Follows Roblox's cylinder rules where the top and bottom are on the X axis, so the height is size.X and the radius is half the smaller of size.Y and size.Z.
SpatialUtils:IsPositionInPart(position, part)
Checks the position against a part, using its actual shape for ball and cylinder parts and a box for everything else.
SpatialUtils:IsPositionInRegion(position, nodes)
Checks the position against the polygon formed by the nodes on the XZ plane. Node order defines the edges and the last node connects back to the first. Height is ignored. Returns whether the position is inside, and the exact distance to the nearest edge whether inside or outside, measured to the tangent point on each edge and clamped to its endpoints.
Package Details
Install command (Click to copy)
Version
1.0.0
License
MIT
Safe for commercial use
Automated license review — not legal advice.
