I am trying to make a Fortnite style game, and I want a third person view from the left side. I've tried this in a LocalScript:
local cam = workspace.CurrentCamera local player = game.Players.LocalPlayer local character = player.Character while cam.CameraSubject == nil do wait(1) end while wait() do cam.CFrame = cam.CameraSubject.Parent.UpperTorso.CFrame * CFrame.new(Vector3.new(5,0,0)) end
Any shape, form, or camera style of help would be appreciated!
Thanks in advance, cooly456
Hello! I see that you are facing troubles using camera. Well that is no problem because I am here to help.
What you have here is pretty much right, you are just missing one vital thing. Whenever you want to manipulate the camera with your scripts, you must change the CameraType. CameraType is a property of camera that changes around how the camera behaves. In order to move the camera on to the side of the play you must use the "Scriptable" type. So using your code here, we are going to edit it a bit:
local cam = workspace.CurrentCamera local player = game.Players.LocalPlayer local character = player.Character while cam.CameraSubject == nil do wait(1) end cam.CameraType = "Scriptable" while wait() do cam.CFrame = cam.CameraSubject.Parent.UpperTorso.CFrame * CFrame.new(Vector3.new(5,0,0)) end
Now technically, that would make your code work just as intended, but I'm going to help you out with a few edits. First off, we are going to implement RenderStepped. RenderStepped fires every time a new frame is rendered. This means that to get the smoothest camera action, we would want to use it because it happens e very frame rather than every .03 seconds. Another thing is that you are linking the camera to the upper torso. This creates a very jittery camera motion because it's cframing relative to the UpperTorso, and the UpperTorso moves because of animations. To combat this we can simply use the Character's HumanoidRootPart as the reference point.
local cam = workspace.CurrentCamera local player = game.Players.LocalPlayer local character = player.Character while cam.CameraSubject == nil do wait(1) end cam.CameraType = "Scriptable" game:GetService("RunService").RenderStepped:connect(function() cam.CFrame = cam.CameraSubject.Parent.HumanoidRootPart.CFrame * CFrame.new(Vector3.new(5,0,3)) end
Also your camera was only off to the side, so I also moved it back on the Z axis 3 ish studs, but feel free to edit that around until it's comfortable for you :D
Thus creates a nifty camera system.
I hope my answered helped
~Lone
You can set the camera view offset under the humanoid.
example
humanoid.CameraOffset = Vector3.new(-2, 0, -2)
wiki page is down atm so cannot link it :/