Hi all, I’m attempting to make a dynamic, fluid feeling camera to compliment the car chassis me and my team are using for our game. I am attempting to make it fairly reusable and independent so that I can just plug in the object instance of any chassis and, as long as I can find its drive seat, it should work. I want to have a smooth, slightly springy camera that follows the diverse movement of the cars. I have attempted to use numerous spring modules to achieve this, and many work quite well getting the desired effect I want.
However, after many iterations of my camera system, I continuously suffer from the camera “stuttering” when the subject is moving. What I mean by this, is the camera will follow the subject in the fluid, dynamic fashion I want, but the subject it is attempting to follow will visibly stutter and jitter around, sort of like screen tearing in a way, and not only is it distracting, but it is quite honestly highly unappealing.
I have redesigned the camera from the ground up, in the simplest and most straightforward way possible, to give a good, raw example of what I mean, without all the fluff and potential performance impacting details of the end result I want. For background info on the Spring Module, it simply solves springs for you, and it is fairly similar to any other spring solver out there: allowing you to plug in a position, target, stiffness and damping intensity. You can see that here:
local Camera = workspace.Camera
local RunService = game:GetService("RunService")
local Player = game.Players.LocalPlayer
local Backpack = Player:WaitForChild("Backpack")
local Char = Player:FindFirstChild("Character")
repeat
Char = Player.Character
wait()
until Char
local Root = Char.HumanoidRootPart
local RootOffset = CFrame.new(Vector3.new(0,8,12))
local SpringModule = require(script.Parent.Spring)
local Spring = SpringModule.new(Camera.CFrame.Position, Root.CFrame:ToWorldSpace(RootOffset).Position)
Spring.omega = 35
if Camera.CameraType ~= 6 then
Camera.CameraType = 6
end
while true do
local total,dt = RunService.Stepped:Wait()
local CarValue = Backpack:FindFirstChild("PlayerValues"):FindFirstChild("CurrentCar").Value
if CarValue then
if CarValue.DriveSeat.Occupant then
if CarValue.DriveSeat.Occupant == Char.Humanoid then
if Camera.CameraType ~= 6 then
Camera.CameraType = 6
end
Spring.target = Root.CFrame:ToWorldSpace(RootOffset).Position
Spring:update(dt)
Camera.CFrame = CFrame.new(Spring.pos) * CFrame.Angles(0,math.rad(Root.Orientation.Y),math.rad(Root.Orientation.Z))
print(CarValue)
else
Camera.CameraType = 4
end
else
Camera.CameraType = 4
end
else
Camera.CameraType = 4
end
end
In this attached video, you can see stutter from the camera that I’ve attached to an A-Chassis vehicle. As a disclaimer, this isn’t a result of A-Chassis, as this happens to many other objects, from basic parts with velocity, to also the player.
(Apologies for the 720p quality, I was originally going to make this a GIF, but I recorded for too long)
In terms of solutions, I have looked for many articles here on the DevForum about camera creation, despite their not being many that fixed/looked into my issue, as well as looking at previous posts, tech demos and resources regarding other people having this issue, but none of them seem to explain what/how they fixed this issue, people just explain an “alternative”.
However, I’m not looking for an alternative way to avoid this, I want to understand why this issue is happening in the first place, and obviously what I can do to fix this.
Any further questions, feel free to ask. All input is appreciated
Thanks, Hirora