Animations not syncing

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

2 Likes

Hi! Just use animation markers for events to sync things. They can be added to animations and fire when a certain point is hit. AnimationTrack | Roblox Creator Documentation

Mark as solution if this helped, please :+1:

1 Like

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.

Playing an animation doesn’t yield a function, this would have no affect

1 Like

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

What if you have multiple checkpoints, and stop the camera from passing them until the animation reaches a certain point?

May I please have your camera animation code and a video of them together? it may just be a simple timing issue.

I tried this but it works inconsistently

					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

1 Like

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