Jump to content

Attempt to index field 'AnimState'


Recommended Posts

Hey everyone! I'm trying to make prefab that'll change animation when some event in the world was pushed. But.. I have some problems now. When the even pused, nothing changes. I've looked into my log, and found that:

attempt to index field 'AnimState' (a nil value)

But I've added animstate! For now I don't know what to do, so I need some help! Thanks everyone for your replies! Oh, and my prefab is here:

local assets_clock_hg =
{
    Asset("ANIM", "anim/clock_hg.zip"),
}

local function Spin(inst)
	inst.AnimState:PlayAnimation("spin_loop",true)
end

local function clock_hg()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddNetwork()
	inst.entity:AddSoundEmitter()

    inst.AnimState:SetBank("clock_hg")
	inst.AnimState:SetBuild("clock_hg")
	inst.AnimState:PlayAnimation("idle",true)

    inst:AddTag("noclick")
    inst:AddTag("FX")
	
	inst:ListenForEvent("Spin_1",Spin,TheWorld)

    inst.entity:SetPristine()
	
    if not TheWorld.ismastersim then
        return inst
    end
	
	local s = 1.75
	inst.Transform:SetScale(s,s,s)
	
	inst.Transform:SetPosition(0,-5,0)

    return inst
end

return Prefab("clock_hg", clock_hg, assets_clock_hg)

 

  • Like 1
Link to comment
Share on other sites

I think it's better to keep bumping of post for old posts that weren't noticed. Forum would be really hard to follow if every 3 hours old post was bumped. Just my point of view, of course.

Sadly i can't help with your problem.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...