I want to achieve a camera system similar to that of jailbreak when you equip a gun.
I have been researching this for about 2 days now, I have tried setting the cameras cframe, as well as humanoid.CameraOffset. However, none of these have worked, and the cframe sort of worked, however it didn’t have the zoom in and out feature.
If anyone could help me or point me in the right direction, that would be deeply appreciated!
Note: I have check roblox’s “Manipulating the camera” however, that did not work for my needs, as no zooming feature. Also, when I say zooming, I mean like being able to use the scroll wheel like in jailbreak, also when you zoom al the way in it puts you in first person.
local run = game:GetService("RunService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local head = character:WaitForChild("Head")
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
while true do
run.RenderStepped:Wait()
camera.CFrame = head.CFrame * CFrame.new(-1, 2, 4)
end
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart")
local human = char:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera
local runService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
human.AutoRotate = false
runService.RenderStepped:Connect(function()
camera.CameraType = Enum.CameraType.Scriptable
UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
local lookAtPos = (hrp.CFrame * CFrame.new(0,0,-10)).Position
local cameraStartPos = (hrp.CFrame * CFrame.new(1.5,2,5)).Position
camera.CFrame = CFrame.lookAt(cameraStartPos,lookAtPos)
end)
this is really good, however ive already tried this kind of thing before, and the only thing its missing is zooming in and out(‘zooming’ as in making the camera go further or closer to the player, and when fully zoomed goes to first person)
It’s easy to make a switch from third person to first person. You can easily change the offset and you can unlock the third person and use the normal camera.
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local human = char:WaitForChild("Humanoid")
local UIS = game:GetService("UserInputService")
local default = UserSettings().GameSettings
local runService = game:GetService("RunService")
local last = nil
local lastFirstPerson = false
local camera = workspace.CurrentCamera
local offset = 2.5
runService.RenderStepped:Connect(function()
if lastFirstPerson ~= ((char.Head.Position - camera.CoordinateFrame.p).magnitude <= 0.5+offset) then
lastFirstPerson = ((char.Head.Position - camera.CoordinateFrame.p).magnitude <= 0.5+offset)
human.CameraOffset = (last and not lastFirstPerson) and Vector3.new(offset,0,0) or Vector3.new(0,0,0)
end
if last == _G.ForceShiftLock then
return
end
last = _G.ForceShiftLock
UIS.MouseBehavior = last and Enum.MouseBehavior.LockCenter or Enum.MouseBehavior.Default
default.RotationType = last and Enum.RotationType.CameraRelative or Enum.RotationType.MovementRelative
human.CameraOffset = last and Vector3.new(offset,0,0) or Vector3.new(0,0,0)
end)
and have player module and this in starter player scripts