I have a script that plays an attack and the animations aren’t syncing correctly since my camera and player animation is in different animations instances but the camera seems to end more early than the player animation and I don’t know how to fix it
What I did try though is
(Serversided Script)
repeat wait() until Animation1.Length > 0
repeat wait() until Animation2.Length > 0
but it still didn’t fix the problem and I’m not sure how else should I sync them
What you can do is when the animation1 is playing use the spawn() function to create a thread which plays the second animation. You can also use coroutine instead of spawn.
Edit; This probably isn’t the best way, but it’s a way none the less.
I did try this already but the main problem is that it’s isn’t synced so the camera animation would always end earlier even if it hits a keyframe marker on the camera animation
local cameraModule = game.ReplicatedStorage:WaitForChild("CameraEffectsModule")
cameraOperator.PrimaryPart.CFrame = CFrame.new(character.HumanoidRootPart.Position)
cameraOperator.PrimaryPart.Orientation = character.HumanoidRootPart.Orientation
cameraOperator.Parent = workspace
local animation1 = cameraOperator.Humanoid.Animator:LoadAnimation(animation1)
local animation2 = Animator:LoadAnimation(animation2)
repeat wait() until animation1.Length > 0
repeat wait() until animation2.Length > 0
cameraModule.FireCamFocus:FireClient(player, cameraOperator.Humanoid)
animation2:Play(0)
animation1:Play(0)
local FF = Instance.new("ForceField",character)
FF.Visible = false
animation1.Stopped:Connect(function()
CameraAnimation:AdjustSpeed(0)
end)
animation1:GetMarkerReachedSignal("Shake"):Connect(function()
--Shake the camera here
end)
animation2:GetMarkerReachedSignal("SummonAura"):Connect(function()
--Mainly the damaging and effects here
end
animation1:AdjustSpeed(0)
animation2:AdjustSpeed(0)
wait(1)
game.ReplicatedStorage.CameraEffectsModule.FireCamFocus:FireClient(player,character.Humanoid)
animation1:AdjustSpeed(1)
animation2:AdjustSpeed(1)
animation1:Stop(0)
animation2:Stop(0)
wait(0.1)
cameraOperator:Destroy()
FF:Destroy()
end)
I took out the damage and effects stuff including stopping the character and stuff robloxapp-20210518-1115306.wmv (3.7 MB)
Sorry for the low framerate by the way
O. I figure I should tell you this now: Animations aren’t a good way to sync things. They are unreliable and break often. I would recommend doing some CFrame manipulation for the camera instead of this. You can keep the humanoid animation, but the camera should be moved with CFrame