#some animations not playing, while others still are.

1 messages · Page 1 of 1 (latest)

junior stirrup
#

experience is owned by my group, there are 3 animations at moment, 'Idle', 'Fire', and 'Equip' all of them exist, are owned by the group, and are on different animation priorities (Idle is set to 'Idle', Equip is set to 'Action1', Fire is set to 'Action4')

the Fire animation is not playing, despite Animation.IsPlaying being true, weight is set to 1, speed is set to 1, and fadeTime is set to 0.

#

animation initialization


local function RetrieveViewmodelData(name: string, timeout: number?): (PhysicalViewmodel?, Instance?)
    timeout = timeout or 1
    
    local folder = Viewmodels:WaitForChild(name, timeout)
    if not folder then return nil, nil end
    
    local viewmodel = folder:WaitForChild("Viewmodel", timeout)
    local animations = folder:WaitForChild("Animations", timeout)
    
    if not viewmodel:FindFirstChild("HumanoidRootPart") then return end
    
    return viewmodel, animations
end
#
local function LoadViewmodelAnimations(physicalViewmodel: PhysicalViewmodel, animations: Instance): { [string]: AnimationTrack }?
    local humanoid = physicalViewmodel:FindFirstChildOfClass("Humanoid")
    local animator = humanoid and humanoid:FindFirstChild("Animator")
    
    if not animator then return nil end

    local loaded = {}

    for _, animation in animations:GetChildren() do
        if animation.ClassName == "Animation" then
            print(animation)
            local track = animator:LoadAnimation(animation)
            loaded[animation.Name] = track
        end
    end

    return loaded
end
#
function Viewmodel.new(skin: string): Viewmodel    
    local physical, animations = RetrieveViewmodelData(skin, 3) -- can take upto 3x timeout time.
    
    -- default to "DEFAULT" if that skin doesn't exist.
    if not physical and not animations then
        physical, animations = RetrieveViewmodelData("DEFAULT", 5)
        if not physical and not animations then
            return warn("Failed to load any viewmodel..")
        end 
    end
    
    local newVM = physical:Clone()
    
    local self = setmetatable({
        Physical = newVM,
        Animations = LoadViewmodelAnimations(newVM, animations),

        Procedural = {
            BobbingSpring = SecondOrder.new(0.7, 0.4, 0.9, Vector3.zero),
            JumpSpring = SecondOrder.new(0.2, 0.6, 0.8, 0), -- will to add custom setintgs evntually (cbf rn)
            
            LastCameraCFrame = CFrame.identity,
            LastSway = CFrame.identity,
            LastRotation = CFrame.identity
        }
    }, {__index = ViewmodelPrototype})

    if not self.Animations then
        warn("Failed to load viewmodel animations.")
    end

    return self
end
#

playing animation

function ViewmodelPrototype:PlayAnimation(name: string): (boolean, AnimationTrack?)
    if not self.Physical then
        return false, print("Physical viewmodel doesn't exist, aborting.")
    end
    
    if not self.Animations then return end

    local animation = self.Animations[name]
    if animation then
        animation:Play(0, 1, 1)

        return animation.IsPlaying, animation
    end

    print(`Failed to play animation '{name}'.`)
    return false
end
--only output comes from here.
print(self.Viewmodel:PlayAnimation("Fire"))
print(self.Viewmodel.Animations)
#

afaik it should 100% be playing

#

and all the other animations are

#
19:08:14.020  true Fire  -  Client - Revolver:136
19:08:14.020   ▼  {
                    ["Equip"] = Equip,
                    ["Fire"] = Fire,
                    ["Idle"] = Idle
                 }  -  Client - Revolver:137
#

i should also mention the rig is the same rig that the animations was created and published with

junior stirrup
#

so

#

for anyone having a simular issue

#

i fixed it by parenting the viewmodel to the workspace