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

How to limit a CFrame/Camera to be bound to a set area?

Asked by 7 years ago

So I created a basic script which moves a Scriptable Camera around according to what you press.

RunService.RenderStepped:Connect(function()
    --// TODO: Create Limit
    if CanMoveCamera then
        cam.CFrame = cam.CFrame + movement
    end
end)

movement is a Vector3 value. It changes when I press certain keys. Like, if I press W, it will get a number, or the speed, added to its X value. This would cause the camera to move while the key is pressed.

I want to know how I could limit this camera to be bound to a box/ rectangular area.

I tried checking the position of the camera before changing movement, but that became very long and tedious, and didn't even really work.

Thanks for any help.

1 answer

Log in to vote
0
Answered by
FiredDusk 1466 Moderation Voter
7 years ago
Edited 7 years ago

--Make a part that can be shaped as a box, because that's what you are kinda wanting.

Make this function in that same script.

game.Workspace.PARTNAME.TouchEnded:connect(function(hit)
    CanMoveCamera = false
end
Ad

Answer this question