Play an animation on 2 rigs at the same time

Hey! I’ve been trying a bit around with animations and wanted to make a 2-player-animation:

As you can see, the animation of the secpmd player is playing a tad faster than the one of the “dragging player”. Please take note that BOTH animations have been loaded earlier and are just being played.

The only solution I found to this yet is to play the animations with 0 speed and adjust them when needed to speed 1. This is simply quite tidious and annoying to do especially since I am “reserving” Action1 with Pre-Loading stuff. Therefore, is there a better solution to achieve this?

This is the outcome with the speed adjustment:
https://gyazo.com/8e3ce032a5674015b68a8cb2c8c3c721

Those are the relevant code snippets:

local SacraficeHandler = {}

local AnimationHandler = require(game.ServerScriptService.Server.AnimationsHandler)
local DraggingHandler = require(game.ServerScriptService.Server.DraggingHandler)

local SacraficePart = game.Workspace:WaitForChild("BurnStation"):WaitForChild("Main")

local inSacrification = false

SacraficePart.ProximityPrompt.Triggered:Connect(function(player)
	if inSacrification then return end
	
	inSacrification = true
	SacraficePart.ProximityPrompt.Enabled = false
	
	local cache = DraggingHandler.LookForDrag(player)
	if cache then
		local corpse = cache.DraggingModel
		local throwMainLength = AnimationHandler:GetLength(player,"CorpseThrowMain")
		local throwCorpseLength = AnimationHandler:GetLength(corpse,"CorpseThrowVictim")

		player.Character.HumanoidRootPart.Anchored = true

		corpse:SetAttribute("Immunity",true)

		DraggingHandler.RemoveToDelete(corpse)
		DraggingHandler.StopDrag(player,true,true)

		AnimationHandler:StopAnimation(corpse,"CorpseLaying")

		corpse.HumanoidRootPart.CFrame = SacraficePart.CharacterPos.WorldCFrame
		player.Character.HumanoidRootPart.CFrame = SacraficePart.CharacterPos.WorldCFrame
		
		task.wait()
		
		AnimationHandler:StopAllAnimations(player.Character,{"CorpseThrowMain"})
		AnimationHandler:StopAllAnimations(corpse,{"CorpseThrowVictim"})
		
		AnimationHandler:AdjustSpeed(player.Character,"CorpseThrowMain",1)
		AnimationHandler:AdjustSpeed(corpse,"CorpseThrowVictim",1)
		
		task.delay(throwMainLength,function()
			player.Character.HumanoidRootPart.Anchored = false
			AnimationHandler:ResumeAnimations(player.Character)
		end)
		
		task.delay(throwCorpseLength,function()
			corpse:Destroy()
		end)
		
		task.wait(throwCorpseLength + 3) -- magic number replace later
		
		inSacrification = false
		SacraficePart.ProximityPrompt.Enabled = true
	end
end)

return SacraficeHandler
local DraggingHandler = {}

local animationsToPrePlay = {
	Player = {
		"CorpseThrowMain",	
	},
	Corpse = {
		"CorpseThrowVictim",	
	}
}

-- dragging stuff

-- somewhere inside the "player 1 begins to drag player 2"
for _,v in animationsToPrePlay.Player do
	warn("pre loading:",v)
    AnimationHandler:PlayAnimation(player.Character,v,0)
end
			
for _,v in animationsToPrePlay.Corpse do
	AnimationHandler:PlayAnimation(model,v,0)
end

return DraggingHandler
local animationsHandler = {}


function animationsHandler:AdjustSpeed(character,animation,spd)
	if loadedAnimations[character] then
		if loadedAnimations[character][animation] then
			loadedAnimations[character][animation]:AdjustSpeed(spd or 1)
		end
	end
end

function animationsHandler:StopAllAnimations(character,exception)
	cachedStopAnims[character] = {}
	
	for i,v : AnimationTrack in loadedAnimations[character] do
		if table.find(exception,i) then else
			if v.IsPlaying then
				table.insert(cachedStopAnims[character],v)
				v:Stop()
			end
		end 
	end
end

function animationsHandler:ResumeAnimations(character)
	if cachedStopAnims[character] then
		for _,v in cachedStopAnims[character] do
			v:Play()
		end
	end
end

function animationsHandler:PlayAnimation(character,animation,spd)
	if loadedAnimations[character] then
		if loadedAnimations[character][animation] then
			if spd then -- preload to 0 speed
				local track : AnimationTrack = loadedAnimations[character][animation]
				track.Priority = Enum.AnimationPriority.Action
				loadedAnimations[character][animation]:Play(nil,nil,spd)
				
				warn("preloaded ",animation)
			else
				loadedAnimations[character][animation]:Play()
			end
		end
	end
end

-- some load stuff
loadedAnimations[character][i] = character.Humanoid.Animator:LoadAnimation(v)
			
local track : AnimationTrack = loadedAnimations[character][i]
track.Priority = Enum.AnimationPriority.Action2

return animationsHandler
1 Like

I think that the pickup animation and other animation are just not synced up with eachother. Did you use something like moon animator to animate them together?

They are made to be played at the same time as the video shows. This is how they are used together in-game with the speed adjusment:
https://gyazo.com/8e3ce032a5674015b68a8cb2c8c3c721

And this is how it looks like when playing both in Moon Animator:
https://gyazo.com/ebe539c6cf8b53a73b2acd25a172d3eb

They are both playing at the same speed, I’m pretty sure according to your first video showing the inaccuracy the player throwing animation stalls for a split second, while the corpse animation starts immediately causing a desync. Where in your code do you play the animation?

Right. That’s the weird part. Both are being played at the same time and have been loaded before as well. I don‘t have the code right now since it’s fixed with the speed adjustment but the 2 animations were both played rights after without a wait or so.

Playing the character animation on the player and the NPC animation on the servers work very well and is not as tideious as the Speed Adjustments.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.