Animation jumping for a frame then setting itself? (fps rig)

Hey, I’m currently dealing with a pretty annoying bug I can’t seem to prevent.

Whenever I equip my weapon, the idle animation is visible for a frame at the start (as evident here)

This does not occur when I don’t call PlayAnimation on the IdleAnim so it’s directly coorelated to that.

I’ve tried to defer stuff to the next frame etc. but the issue is still persistent.

function Rig:EquipWeapon( gunName ) : nil
  
    local weapon = ReplicatedStorage.Assets.Weapons[gunName]:Clone()
    
    --TODO: Create a method to retrieve all animations corresponding to a weapon
    local idleAnimationName = "Idle"..gunName
    local equipAnimationName = "Equip"..gunName

  
    local rigGrip  = self._rig.PrimaryPart.Handle
    weapon.Parent = self._rig
    rigGrip.Part1 = weapon.Handle

    local animation = self:PlayAnimation(equipAnimationName)
    local stoppedConnection
    stoppedConnection = animation.Stopped:Connect(function()
        self:PlayAnimation(idleAnimationName) -- Removing this causes it not to occur
        stoppedConnection:Disconnect()
    end)

end

Because the animation takes a second to load. Try :LoadAnimation() in an animation table or something, that loads the second that the weapon is in the inventory.

1 Like

The animation is already loaded using my SetupAnimations method

function Rig:SetupAnimations( animations : {} ): nil
    local rig : Model = self._rig :: Model
    assert( rig, "Rig does not exist" )

    --Ensure animator is an animator
    local animationController : AnimationController = rig.AnimationController :: AnimationController
    rig.Parent = workspace
    for _ : number, _animation : Animation in ipairs ( animations ) do
        if ( _animation ) then
            self.animations[_animation.Name] = animationController:LoadAnimation(_animation)
        end
    end
    rig.Parent = self._camera
end

It’s probably loading the animation then. because it looks like its loading the animation, or something.