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

CFrame doesnt place correctly in lerp code?

Asked by 6 years ago

The front is lined up but the camera doesn't move to the place fully, its normally off center or won't fully move there.

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera

Camera.CameraType = Enum.CameraType.Scriptable

for Num = 0,.7,0.1 do
        Camera.CFrame = Player.Character.HumanoidRootPart.CFrame:lerp(workspace.Desk.Hi.CFrame,Num)
        game:GetService('RunService').RenderStepped:wait()
end

thanks,

0
Hmm, how is it possible if you were able to make Wait on the 2nd line but did wait on the 9th line, is it a typo? saSlol2436 716 — 6y
0
":wait" is deprecated; use ":Wait" in both cases. chess123mate 5873 — 6y

2 answers

Log in to vote
-1
Answered by 6 years ago

You need to lerp all the way to '1' unless you only want it to get 70% there. If you want it done in exactly 8 steps (7 waits), you'll need to change the 'step' value accordingly. Do note that you should assign the CFrame to the final value after the loop is done to ensure that it worked properly (in case the for loop doesn't run with Num == 1, which may happen depending on what step value you give it).

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera

Camera.CameraType = Enum.CameraType.Scriptable

for Num = 0,1,0.15 do
        Camera.CFrame = Player.Character.HumanoidRootPart.CFrame:lerp(workspace.Desk.Hi.CFrame,Num)
        game:GetService('RunService').RenderStepped:Wait()
end
Camera.CFrame = workspace.Desk.Hi.CFrame
Ad
Log in to vote
0
Answered by
CootKitty 311 Moderation Voter
6 years ago

Just use cam:Interpolate()

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera

Camera.CameraType = Enum.CameraType.Scriptable

Camera:Interpolate(workspace.Desk.Hi.CFrame, workspace.Desk.Hi.CFrame*CFrame.new(0,0,-1), 5)

Answer this question