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