Help with delta time

I have a main menu inspired by Shinobi Life 2, but on higher fps the camera moves very quickly compared to 60fps. I don’t have much experience with delta time so i was hoping someone could help me understand where to apply it.

Video:

Code:

RenderStepped = RunService.RenderStepped:Connect(function(dt)
local CameraCF

  local PartCF = MenuCams[scrollValue].CFrame
  if not transition then
  	

  	local Sine = math.sin(1 * os.clock()) / 45
  	local Cos = math.cos(1 * os.clock()) / 45

  	CameraCF = PartCF * CFrame.new(Cos, Sine, 0) * CFrame.Angles(Cos, Sine, Cos / 2)
  else
  	local controlOffset = MathFunctions.offsetMidpointInCircle(startCF.Position, PartCF.Position, 40, 45)
  	
  	local halfPoint = (startCF.Position + PartCF.Position) / 2
  	
  	local controlPoint = Vector3.new(controlOffset.X, halfPoint.Y + 5, controlOffset.Z)
  	
  	local newPos = Interpolation.QuadBezier(startCF.Position, controlPoint, PartCF.Position, t)
  	local x, y, z = PartCF:ToEulerAnglesXYZ()
  	
  	
  	
  	CameraCF = CFrame.new(newPos) * CFrame.Angles(x, y, z)
  	
  	local mag = (PartCF.Position - CameraCF.Position).Magnitude
  	
  	if mag <= 0 then
  		transition = false
  	end
  	
  	
  	
  	t += 1/45
  end
  
  Camera.CFrame = Camera.CFrame:Lerp(CameraCF, 0.03)
  
  local vel = (Camera.CFrame.Position - lastCamPosition).Magnitude / dt
  lastCamPosition = Camera.CFrame.Position
  
  WindSFX.Volume = vel / 300
  WindSFX.PlaybackSpeed = vel / (100 * rand)
  
  
  calculateMotionBlur(vel)
  calculateFOV(vel)
end)

You should multiply the speed over a second by the delta, not divide it.

The RenderStepped event fires every frame per second as mentioned in the roblox documentation about runservice, you usually use runservice with objects by a change in position or cframe with respect to time by constantly multiplying it with deltaTime every frame per second.

I have commented on a post that was similar to this:
Movement script behavior changes depending on where I launch the game from? - Help and Feedback / Scripting Support - Developer Forum | Roblox

local vel = (Camera.CFrame.Position - lastCamPosition).Magnitude * dt

Yes I understand that I need to use delta time, I just don’t know what to apply it to. I’m mainly looking to fix the position. For that script I divided it by delta time because I was looking for the velocity. Velocity is distance / time. The issue i’m having is with the movement of the camera, I multiplied dt to the time value, and the positional value and neither worked correctly.

What relevance does the variable “t” mean here?

Does disregarding deltaTime change anything at all?

t is just the time value i use for the bezier function, multiplying 1/45 by delta time just results in very slow movement.

Everything I said was completely wrong, dthecoolest had a formula where your lerp constant is set to something like this:

local lerpTimeConstant = 1-math.pow(0.1,10*dt)
Camera.CFrame = Camera.CFrame:Lerp(CameraCF, lerpTimeConstant)

The change of frames messes with the lerping cycle.

Lerp to change CFrame angles inconsistent with FPS - Help and Feedback / Scripting Support - Developer Forum | Roblox

It didn’t really change anything, what is that formula supposed to be doing? It actually made it much worse honestly.

local lerpTimeConstant = 1-math.pow(0.5,10*dt)

The value I replaced 0.1 with was 0.5 since the base was too small, are there segments of your code that shows the purpose of variable t and are you still dividing by dt? Only line that uses deltaTime is here

That solved the issue of the rotation, but the position is still different based on fps. The variable t is used for the quad bezier function

local newPos = Interpolation.QuadBezier(startCF.Position, controlPoint, PartCF.Position, t)

function Interpolation.QuadBezier(a, b, c, t)
return (1 - t)^2a + 2(1 - t)tb + t^2*c
end

I fixed the issue, i just divided delta time by the duration i wanted the transition to take

code:

t += dt / transitionDuration

Never seen transitionDuration anywhere there, I was about to say either t += dt or apply deltaTime with the translated position based on whatever t is.

The way this was worded had me confused for some time

Yet again, this should have worked for both the position and rotation unless the quadBezier module had something to do with this