#2D camera boundaries

1 messages · Page 1 of 1 (latest)

spice oracle
#

I want the camera to stop following the character when they get close enough to a wall or the roof, whats the best way to implement this?

#

ive thought about using math.clamp but that would be a hassle

final meadow
#

Instead of 1 or 2 rays, cast several rays around the camera direction and take the closest hit.

#
    Vector3.new(0, 0, 0),
    Vector3.new(0.5, 0, 0),
    Vector3.new(-0.5, 0, 0),
    Vector3.new(0, 0.5, 0),
    Vector3.new(0, -0.5, 0),
}

local closestDist = MAX_DIST
local finalPos = desiredPos

for _, offset in ipairs(offsets) do
    local dir = (desiredPos + offset) - root.Position
    local result = workspace:Raycast(root.Position, dir, params)

    if result then
        local dist = (result.Position - root.Position).Magnitude
        if dist < closestDist then
            closestDist = dist
            finalPos = result.Position + result.Normal * 0.3
        end
    end
end

camera.CFrame = CFrame.new(finalPos, root.Position)```
spice oracle
#

is ts AI bruh

#

i also kinda thought about ts, detecting invis parts with tags