AnimationTrack refuses to play unless it is played and stopped after creation

Trying to play an animation on a ViewModel rig with an AnimationController fails unless I call Track:Play() and Track:Stop() immediately after creation.

Without Track:Play() and Track:Stop()

With Track:Play() and Track:Stop()

Expected behavior

I expect to be able to play animations on my rig without having to use this hacky workaround

local Animation = Weapon.Model.Animations[Name]
local ClonedAnimationTrack = Animator:LoadAnimation(Animation)

ClonedAnimationTrack:Play() --Both required else :Play() will fail later on
ClonedAnimationTrack:Stop()

--later on in another function call
ClonedAnimationTrack:Play()

Reproduction provided in staff-only as I was only able to narrow it down to a small portion of my gun system

A private message is associated with this bug report

2 Likes

Have you tried preloading your animations first? I think it will not play since the animation is not really loaded yet. I assume your function looks like this:

local function SomeFunctionName(Name)
  local Animation = Weapon.Model.Animations[Name]
  local ClonedAnimationTrack = Animator:LoadAnimation(Animation)

  ClonedAnimationTrack:Play() --Both required else :Play() will fail later on
  ClonedAnimationTrack:Stop()
end

what I would do is load all animations first and place it in a table

local loadedAnimTracks = {}

then when needed, just reference to that animation:

loadedAnimTracks[Name]:Play()