Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Camera is not being positioned right so that it can lerp towards the player's position?

Asked by
xPolarium 1388 Moderation Voter
6 years ago
Edited 6 years ago

My title can be entirely wrong to understand but basically:

I'm manipulating the camera so that it stays at a certain spot but I also want it to look at the player's HumanoidRootPart using the :Lerp() function for CFrame.

What happens in this script is that the camera is kinda lerping but it instead goes towards the part I have defined. I want instead the opposite: the camera focus to lerp towards the players position when ever they move but also stay on the position of the Part.

--this is a local script:
local RS = game:GetService("RunService")

local player = game.Players.LocalPlayer
local camera = game.Workspace.CurrentCamera

local part = game.Workspace:WaitForChild("Part")

camera.CameraType = Enum.CameraType.Scriptable

local smoothSpeed = 0.005 

RS.RenderStepped:Connect(function()
    local playerHum = player.Character:FindFirstChild("HumanoidRootPart").CFrame
    camera.CFrame = camera.CFrame:lerp(CFrame.new(part.Position, playerHum.p), smoothSpeed)
end)

Should I experiment with other CameraTypes and Focus/Subject? Or should I try using a custom lerp function?

Answer this question