Help needed fixing animation transitions

I edited the default animate script to ease in/out the transition between animations, it works by tweening the weight of the last animation to 0 and the new animation to 1.

The issue is that every time the animation changes the rig its playing on will tween to standing still then to the new animation, instead of the rig parts takin the fastest path to the new pose.

function playAnimation(animName, transitionTime, humanoid)

local roll = math.random(1, animTable[animName].totalWeight)
local origRoll = roll
local idx = 1
while (roll > animTable[animName][idx].weight) do
roll = roll - animTable[animName][idx].weight
idx = idx + 1
end
– print(animName … " " … idx … " [" … origRoll … “]”)
local anim = animTable[animName][idx].anim

– switch animation
if (anim ~= currentAnimInstance) then

  local LastAnimTrack
  if (currentAnimTrack ~= nil) then
  	LastAnimTrack = currentAnimTrack
  	task.spawn(function()
  		LastAnimTrack:AdjustWeight(1)
  		local value = Instance.new("NumberValue")
  		local Tween = TweenService:Create(value,TweenInfo.new(2,Enum.EasingStyle.Exponential,Enum.EasingDirection.In), {Value = 0})
  		Tween:Play()
  		game:GetService("Debris"):AddItem(value,Tween.TweenInfo.Time)
  		local stop = false
  		Tween.Completed:Connect(function()
  			stop = true
  			value:Destroy()
  		end)
  		repeat task.wait()
  			LastAnimTrack:AdjustWeight(value.Value)
  		until stop == true
  		LastAnimTrack:Stop()
  		LastAnimTrack:Destroy()
  	end)
  end

  currentAnimSpeed = 1.0

  -- load it to the humanoid; get AnimationTrack
  currentAnimTrack = humanoid:LoadAnimation(anim)
  currentAnimTrack.Priority = Enum.AnimationPriority.Core
   
  -- play the animation
  currentAnimTrack:Play(transitionTime)
  currentAnim = animName
  currentAnimInstance = anim
  
  task.spawn(function()
  	currentAnimTrack:AdjustWeight(0)
  	local value = Instance.new("NumberValue")
  	local Tween = TweenService:Create(value,TweenInfo.new(2,Enum.EasingStyle.Exponential,Enum.EasingDirection.Out), {Value = 1})
  	Tween:Play()
  	game:GetService("Debris"):AddItem(value,Tween.TweenInfo.Time)
  	local stop = false
  	Tween.Completed:Connect(function()
  		stop = true
  		value:Destroy()
  	end)
  	repeat task.wait()
  		currentAnimTrack:AdjustWeight(value.Value)
  	until stop == true
  end)
  -- set up keyframe name triggers
  if (currentAnimKeyframeHandler ~= nil) then
  	currentAnimKeyframeHandler:disconnect()
  end
  currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)

end

end

ended up figuring out what my issue was

… so what was the issue?

i forgot to set first value that was being tweened to the animation weight of that animation

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