Hello.
I am currently making an RPG game with a third person view.
And as I am not good and math related programming nor cameras. I got this script from this thread.
And I am currently using @ImFarley script. And as it works just like I want it too. It is (no offence) quite laggy and glitchy if I may say.
Hey, I can’t even make one so it sounds a bit complaining (which I am not!).
But, I was wondering if there was any better way of doing this and make it more smooth.
One of my favourite games POLYGUNS does this in a great way, and @SnakeWorl one of the creators, has managed that fine (maybe you also can aid me?).
Game link:
ThirdPersonCamera.rbxl (18.7 KB)
And here is a gif, showing what I mean.
https://gyazo.com/7727cc26e56df14dda932246e30e4251
Thank you very much for all help, and again. Thank you @ImFarley
So anyway, here is the script.
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”)
hum.CameraOffset = Vector3.new(4, 0, 0)
hum.AutoRotate = false
cam.CameraSubject = hum
game:GetService(“RunService”).RenderStepped:Connect(function()
uis.MouseBehavior = Enum.MouseBehavior.LockCenter
local delta = uis:GetMouseDelta()
local deltaX, deltaY = delta.X, -delta.Y
cam.CFrame = CFrame.new(cam.CFrame.p, cam.CFrame* CFrame.new(deltaX, deltaY, -2000).p)
local offset = char.LowerTorso.CFrame:ToWorldSpace(CFrame.new(0, char.UpperTorso.Size.Y/2, 0)) * CFrame.fromEulerAnglesXYZ(math.max(math.min(math.asin((mouse.Hit.p - mouse.Origin.p).unit.y), .6), -.75), 0, 0) * CFrame.new(0, char.UpperTorso.Size.Y/2, 0)
waist.C1 = offset:inverse() * char.LowerTorso.CFrame * CFrame.new(0, .8, 0)
local tweenInfo = TweenInfo.new(.15, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
local newRootCF = CFrame.new(root.CFrame.p,root.CFrame.p+Vector3.new(cam.CFrame.lookVector.X,0,cam.CFrame.lookVector.Z))
local tween = ts:Create(root, tweenInfo, {[“CFrame”] = newRootCF}, true)
tween:Play()
end)```