Camera Tweening "Gitters"

Hello, I am working on a speeder bike and want to tween the camera behind the bike in order to follow it. Currently it looks like this:


I tween the camera every frame. Any tips?

Note
When I simply position the camera behind the speeder every frame it does not have the gitter problem. Its only when I am tweening

function tween(object, values, timeVal)

    local tweenInfo = TweenInfo.new(timeVal or 1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)

    ts:Create(object, tweenInfo, values):Play()

end

tween(cam, {CFrame = CFrame.new(cf.p, (driverSeat.CFrame * CFrame.new(0,0,-20)).p)},0.05)

Might be me, but I don’t see disturbsion in the video.

What exactly do you mean? :slight_smile:

Visit this game: Clone Wars Universe - Roblox

I recommend use lerp and update it with ({game:GetService(“Stepped”)})[2].
Something like this:

local Services = {
	PLS = game:GetService("Players");
	RS = game:GetService("RunService")
}
local Plr = Services.PLS.LocalPlayer
local Char = Plr.Character or Plr.CharacterAdded:Wait()

local Camera = workspace.CurrentCamera

local Pos, Offset, Base = Vector3.new(), Vector3.new(0, 1.5, 5)

local function Lerp(A, B, C)
    return A+((B-A)*C)
end

Services.RS:BindToRenderStep("Cam", Enum.RenderPriority.Camera.Value+1, function()
	Camera.CameraType = "Scriptable"
	
	Base = CFrame.new(Pos)+Offset
	
	Camera.CFrame = Base
	
	Pos = Lerp(Pos, Char.PrimaryPart.Position, ({Services.RS.Stepped:Wait()})[2]*10) --Update, Stepped is the physics per frame,  Update*Speed
end)
3 Likes

This has removed the gitter effect thank you! However, the camera is stuck always facing one direction (it not longer turns with the vehicle).

The camera should be behind the vehicle, so that the user can control it with the mouse.

1 Like

I can see your actual code or the Rbxm?

1 Like

Okay, maybe this is the problem, the angle isn’t correct at the body, I fixed it

local Services = {
	PLS = game:GetService("Players");
	RS = game:GetService("RunService")
}
local Plr = Services.PLS.LocalPlayer
local Mouse = Plr:GetMouse()
local Char = Plr.Character or Plr.CharacterAdded:Wait()

local Camera = workspace.CurrentCamera

local CF, Offset = CFrame.new(), CFrame.new(0, 1.5, 5)
local Lerp = CFrame.new().Lerp --Archived function

Services.RS:BindToRenderStep("Cam", Enum.RenderPriority.Camera.Value+1, function()
	Camera.CameraType = "Scriptable"
	
	Camera.CFrame = CF*Offset
	
	CF = Lerp(CF, Char.PrimaryPart.CFrame, ({Services.RS.Stepped:Wait()})[2]*10) --Physic frames per second
end)
2 Likes

That works! Thank you very much for your help.

1 Like