I have a cutscene where the camera continuesly tweens between positions and it’s meant to look like continous motion but it clearly slows down and stops before starting the next move, any advice?
Supporting Video:
As you can see, you can see and feel when it starts tweening between different invisible objects on the path:
Some of this is obviously down to fine tuning the speed so it increases/slows down at a good pace, that said you can clearly see the camera slowing down to a stand still before tweening again.
What have i tried to fix it so far:
- Tuning TweenInfo speed.
- Swapping out
Animation.Completed:Wait()
forwait(tonumber(array[1])-0.5)
- Checking calculation overhead for each tween.
- Changing wait time to change to next tween earlier.
My system uses a module for camera and :Play() from a require to call it. All the cutscene camera animation information is included in here:
Enclosed is my code aside the Camera shake code. I can also provide the testing file if need be
--| Cutscene Core
--| By: jeditcdisback
--| March 2th, 2020
--| Handles Camera
local Workspace = game:GetService("Workspace")
local TweenService = game:GetService("TweenService")
local CurrentCamera = Workspace.CurrentCamera
local FolderCutscenes = Workspace:WaitForChild("Cutscenes")
local Camera = {}
local t = 0
local Stop = false
local Permitted = false
local threshold = 5
local ToBooleans =
{
["true"] = true;
["false"] = false
}
function PerlinNoise(Strength)
t = t + Strength
local x = math.noise(t)
return x
end
function Camera.new(Pref)
local self = setmetatable({}, Camera)
self.Cutscene = Pref.SpecifiedCutscene or nil
self.RequestType = Pref.Type
self.CameraType = CurrentCamera.CameraType
Completed = false
local Cutscene = FolderCutscenes:FindFirstChild(self.Cutscene) or nil
function self.Shake(Type,ReqCam,Strength,Speed,StartTime,EndTime)
end
--| Changes Camera position and Type
--| General Use: Cutscenes, Single Shots.
function self.Play()
CurrentCamera.CameraType = Enum.CameraType.Scriptable
for _,v in pairs(Cutscene:GetChildren()) do
--| Setup Start
local array = string.split(v.TweenInfo.Value)
local TI = TweenInfo.new(tonumber(array[1]), Enum.EasingStyle[array[2]], Enum.EasingDirection[array[3]],tonumber(array[4]),ToBooleans[array[5]], tonumber(array[6]))
local To = {CFrame = v.CFrame}
Animation = TweenService:Create(CurrentCamera,TI,To)
--| Setup End
--| Shake while Tween
if v:FindFirstChild("CameraShake") then
local CameraShakeInfo = string.split(v.CameraShake.Value)
wait(0.5)
Stop = false
Permitted = false
self.Shake("Camera",v,tonumber(CameraShakeInfo[1]),tonumber(CameraShakeInfo[2]),tonumber(CameraShakeInfo[3]),tonumber(CameraShakeInfo[4]))
wait(CameraShakeInfo[3])
Permitted = true
wait(CameraShakeInfo[4])
Permitted = true
--|No Shake
else
print(v.Name," Started")
Animation:Play()
wait(tonumber(array[1])-0.5)
print(v.Name," Ended")
end
end
Completed = true
CurrentCamera.CameraType = self.CameraType
end
--| Hides Parts within the specified cutscene folder
function self.HideCam()
print(Cutscene)
for _,v in pairs(Cutscene:GetChildren()) do
v.Transparency = 1
for _, instance in pairs(v:GetDescendants()) do
if instance:IsA("Texture") then
instance:Destroy()
end
end
end
end
--| Takes requests and calls the module type
if self.RequestType then
print("[Camera Module]: CALLED "..self.RequestType)
self[self.RequestType]()
end
return Completed
end
return Camera
I appreciate all advice given and this may just me being dumb, I admit, I am not great at TweenInfo as there is a lack of detail as to what each option does. TweenInfo value object only includes the following:
The highlighted is the only value which changes.
Small update, some were getting confused by my wording of the issue so EriChan1235 said it alot better: