I have read the tutorial about custom camera control here and got the basic understanding of it. I think the camera script in the tutorial was intended for R6 users, as it was dealing with torso of the character.
I wanted to create a basic custom camera which would be pointing to the game character and is initially placed a certain distance away from the character spawn location. After the spawn of the character, if the character move or jump in any direction my camera should also make the same move with respect to the character maintaining a certain distance.
I did little search in the internet and came up with the following code for R15 model
local camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
local runService = game:GetService('RunService')
local pre, curr, diff
local function setupCamera()
wait()
pre = player.Character:WaitForChild("UpperTorso").Position
camera.CFrame = CFrame.new(pre+Vector3.new(0, 5, 10), pre)
end
local function onUpdate()
if pre and player.Character and player.Character:FindFirstChild("UpperTorso") then
curr = player.Character.UpperTorso.Position
diff = curr - pre
pre = curr
camera.CFrame = camera.CFrame + diff
end
end
player.CharacterAdded:connect(setupCamera)
runService:BindToRenderStep("Camera",Enum.RenderPriority.Camera.Value,onUpdate)
The code ran as I expected it to be, but when I hit play in studio and move character the camera movement is not as smooth as the default roblox studio camera. I can see the walking type movement of my camera as it follows the character.
I tested the same code with the R6 character model by replacing UpperTorso to Torso. The R6 model gave me smooth results. R15 model has quite a little jump type camera movement. I believe it is because of the more parts involved in the character which makes the character move more realistic and in turn making my camera behave like that.
I tried to point my camera to the Head and LowerTorso but I still see the same movement.
So how can I make the camera move smoothly like the default camera does for the R15 Character model.

2 comments
Thanks a lot, after replacing "HumanoidRootPart" it works like a charm :D
No problem. :P