Ah okay.
You will need to first need to figure out how long you want the cutscene to last, let’s say we want to move the camera along a bezier curve and we want the whole movement to take 10 seconds. In that case, we need to first make a variable that tells us how much time has passed, then just add to it every time a frame has passed. For example:
local goalTime = 10
local timePassed = 0
runService.RenderStepped:Connect(function(dt)
timePassed += dt
end)
Since dt is the amount of time that has passed between the previous and current frame, we can use this to get our time to pass to the bezier function. Doing this is pretty easy, it’s just timePassed / goalTime
. This will typically give a number between 0 and 1. If you want to be super precise you can clamp it but it really isn’t necessary as it’s typically not noticeable. It might actually look better if you don’t clamp it as interpolation functions can accept numbers <0 and >1.
Suppose lerp is a function that returns some data type linearly interpolated between p1 and p2, at time. It can be simplified if you’re just working with numbers but given the fact that you’re working with cutscenes, I would assume you’d be working with CFrames or vectors, in that case you could just do p1:Lerp(p2, time)
in place of lerp(p1, p2, time).
But I digress, let’s continue.
local function quadraticBezier(p1, p2, p3, time) -- returns the point along the curve at 'time'
return lerp(lerp(p1, p2, time), lerp(p2, p3, time), time)
end
local goalTime = 10
local timePassed = 0
runService.RenderStepped:Connect(function(dt)
timePassed += dt
local percentageComplete = timePassed / goalTime
-- finally,
camera.CFrame = quadraticBezier(p1, p2, p3, percentageComplete)
end)
What’s cool is that you can also use the percentageComplete to get easing styles by passing it to TweenService:GetValue()
Anyway, sorry for my rambling but that should hopefully help get you started.