Is there any way for a developer to implement a third person style camera similar to shift lock mode?
The camera bit isn’t so hard but as soon as we cut to CameraType = Scriptable the player will no longer face the camera, so it’s back to the drawing board there.
Know this is something people have been trying to do for a long time, has anyone figured out a neat way yet?
I believe the player’s humanoid faces the camera’s direction if AutoRotate is enabled. If this doesn’t happen during the scriptable type, then I’d disable it and use rotvelocity to adjust the player to face the camera.
UserInputService.InputChanged:connect(function(IO)
if IO.UserInputType == Enum.UserInputType.MouseMovement then
X = IO.Delta.X/150
Y = math.clamp(Y-IO.Delta.Y/150,-1,1)
end
end)
game["Run Service"].RenderStepped:connect(function()
Camera.CFrame = Char.HumanoidRootPart.CFrame * CFrame.new(Vector3.new( 0,2.5,.25)+Char.Humanoid.CameraOffset)*CFrame.fromEulerAnglesXYZ(Y,0,0)*CFrame.new(XOffest,0,6)
Char.HumanoidRootPart.CFrame = Char.HumanoidRootPart.CFrame * CFrame.fromEulerAnglesXYZ(0,-X,0)
X = 0
end)
Char being Character, and Camera being the camera…
play around with the variables, see what happens.
EDIT: I’ve learned a bit in the 2 years since i posted this, so I’ve made a few minor changes
you can skip all that logic stuff by using math.clamp (which i didn’t know was a thing)
You could at least explain how it doesn’t work, such as what problems you’re running into. This thread is two years old so the methods since then would have very obviously changed. It’d be better to create a new thread than to bump something very old.
Roblox is natively capable of a very rudimentary third person camera through the manipulation of Humanoid.CameraOffset a certain amount of studs on the X coordinate.
I’ve been told off before for creating a new thread when an older thread already existed
As for the problems, 1. ‘XOffset’ is never defined and 2. If I replace XOffset with a 0 I get this error
UserInputService.InputChanged:connect(function(IO)
if IO.UserInputType == Enum.UserInputType.MouseMovement then
X = IO.Delta.X/150
Y = math.clamp(Y-IO.Delta.Y/150,-1,1)
end
end)
game["Run Service"].RenderStepped:connect(function()
Camera.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(Vector3.new( 0,2.5,.25)+Character.Humanoid.CameraOffset)*CFrame.fromEulerAnglesXYZ(Y,0,0)*CFrame.new(0,0,6) -- ERROR HERE
Character.HumanoidRootPart.CFrame = Character.HumanoidRootPart.CFrame * CFrame.fromEulerAnglesXYZ(0,-X,0)
X = 0
end)
I wanted to do this exact thing a couple months ago. I’ll save you the time it took me to figure it out haha
Edit: Sorry, originally gave un-tested code. This code should work as I just tested it:
local uis = game:GetService(“UserInputService”)
local ts = game:GetService(“TweenService”)
local cam = workspace.CurrentCamera
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
repeat wait() until plr.Character and plr.Character.Parent == workspace
local char = plr.Character
local hum = char:WaitForChild(“Humanoid”)
local waist = char.UpperTorso:WaitForChild(“Waist”)
local root = char:WaitForChild(“HumanoidRootPart”)