Jump to content

Recommended Posts

So I've got a stategraph, with a state called "leave". The only problem is, it doesn't ever hit the "animover" event. It keeps looping the event and the animation over and over.

 

	State{
        name = "leave",
        tags = { "busy" },
        onenter = function(inst, target)
			inst.SoundEmitter:KillSound("danger_music")
            inst.AnimState:PlayAnimation("leave")
        end,
		
        events =
        {
            EventHandler("animqueueover", function(inst) inst.Remove() end),
        },
    },

It might be in the brain, but I do not see why this would re-invoke and keep trumping the original event... other prefabs didn't seem to need to check if they were re-entrant safe

function prefab_brain:OnStart()
    local root = PriorityNode(
		{
			WhileNode(function() return WantsToEat(self.inst) end, "eating", DoAction(self.inst, MY_EAT)),
			ActionNode(function() return self.inst.sg:GoToState("leave") end)
		},
		.25
	)
    
    self.bt = BT(self.inst, root)
end

 

Anyone know what I am missing here?

Edited by realitymeltdown
	State{
        name = "leave",
        tags = { "busy" },
        onenter = function(inst)
			inst.components.health:SetInvincible(true)
            inst.Physics:Stop()
            RemovePhysicsColliders(inst)            
            inst.AnimState:PlayAnimation("leave")
            inst:SetBrain(nil)
        end,
		
		events=
        {
			EventHandler("animover", function(inst) inst:Remove() end),
        },   
    },

For anyone reading this, I checked the Krampus brain - which had nearly identical code to my original, except it removed the brain (spooky!). That appeared to get it to properly abandon ship

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
×
  • Create New...