Hey guys! I recently made a scriptable camera setup that looks something like the indoors in Loomian Legacy. And I also bumped into a few problems so can anyone figure it out?
I didn’t record this video in my real game. I just copied the code and made a few parts.
Screenshots & Videos
The part on the left deactivates the scriptable camera, called ChangeCam2
The part on the right activates the scriptable camera, called ChnageCam
The video quality might be bad.
Problems
- I can see through a wall. I can edit my walls to make it look good, but is there anyway to stop the player from seeing through a wall?
- My head is a bit (actually super) shaky. The cam doesn’t shake because the CameraSubject is the
HumanoidRootPart
- The camera doesn’t change back to what it should be.
I haven’t found any solutions to these three on the internet yet.
Script
local function CamCFrame(position, lookAt)
local lookVector = (lookAt - position).Unit
local modelUpVector = Vector3.new(0, 1, 0)
local rightVector = lookVector:Cross(modelUpVector)
local upVector = rightVector:Cross(lookVector)
return CFrame.fromMatrix(position, rightVector, upVector)
end
local camera = workspace.CurrentCamera
game.Players.LocalPlayer.CharacterAdded:Wait()
local character = game.Players.LocalPlayer.Character
workspace.ChangeCam.ClickDetector.MouseClick:Connect(function()
camera.CameraType = Enum.CameraType.Scriptable
repeat wait(0.01)
camera.CFrame = CamCFrame(character.HumanoidRootPart.Position + Vector3.new(11,10,0), character.HumanoidRootPart.Position)
until camera.CameraType == Enum.CameraType.Follow
end)
workspace.ChangeCam2.ClickDetector.MouseClick:Connect(function()
camera.CameraType = Enum.CameraType.Follow
end)