Virvek
(Virvek)
July 28, 2025, 2:05am
1
I’m trying to make a very similar trail effect with the camera offset. But I just can’t seem to get it to work right.
This is the goal:
Here is my code, but it just doesn’t seem to be the same way:
local smoothingSpeed = 8
game:GetService("RunService").RenderStepped:Connect(function(dt)
local vel = rootPart.Velocity
local walkspeed = char.Humanoid.WalkSpeed
local horizontalVel = Vector3.new(vel.X, 0, vel.Z)
local speed = horizontalVel.Magnitude
local moveDir = speed > 0.1 and horizontalVel.Unit or Vector3.zero
local trailDistance = 3 * speed / (walkspeed * 2)
local worldOffset = -moveDir * trailDistance
local localOffset = rootPart.CFrame:VectorToObjectSpace(worldOffset)
local verticalOffset = math.clamp(vel.Y / 30, -5, 5)
local targetOffset = Vector3.new(localOffset.X, verticalOffset, localOffset.Z)
local currentOffset = char.Humanoid.CameraOffset
local alpha = 1 - math.exp(-smoothingSpeed * dt)
char.Humanoid.CameraOffset = currentOffset:Lerp(targetOffset, alpha)
end)
1 Like
If you don’t want to use a custom camera type or fixed camera type, it will be absolutely necessary to edit the camera module. It’s not that hard. Just change the part where it sets the CFrame to lerp instead.
Virvek
(Virvek)
July 28, 2025, 2:31am
3
I did take a look at the module, but was unable to locate the CFrame that is being set.
It’s difficult to locate, and it’s been a while since I’ve modified it. It might be in a module called BaseCamera though. It’s in one of them.
1 Like
Virvek
(Virvek)
July 28, 2025, 4:53am
5
Thank you so much! This is what I did:
Made a copy of the camera from the roblox.
Opened the BaseCamera module
In the GetSubjectPosition I changed:
result = bodyPartToFollow.CFrame.p + bodyPartToFollow.CFrame:vectorToWorldSpace(heightOffset + cameraOffset)
too:
local targetPosition = bodyPartToFollow.CFrame.p + bodyPartToFollow.CFrame:vectorToWorldSpace(heightOffset + cameraOffset)
result = result:Lerp(targetPosition, 0.1)
Quick question, since I made a copy of the entire camera script and put it into StarterPlayerScripts will there be any issues?
1 Like
system
(system)
Closed
August 11, 2025, 4:53am
6
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.