Jump to content

Recommended Posts

Hello, everyone! Here are my questions, any help is welcome and much appreciated of course (and could benefit someone else reading this) :

  • How do you make a creature a follower upon crafting it? -- (the crafting is possible right?).
    • I know you need the follower component but actually befriending him, especially upon crafting him, is something I don't know where to start with.
  • How does walking work in stategraphs? I have this thing as an example but I have no idea how to adjust the timing for the animations I have made (I don't know how any of these lines actually work, especially TimeEvent ones of course). Could anyone provide info on what these lines do and how to use them? :)
 CommonStates.AddWalkStates(states, {
    walktimeline = 
    { 
        TimeEvent(0*FRAMES, function(inst)  end),
        TimeEvent(1*FRAMES, function(inst) 
            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/boing")
            inst.components.locomotor:RunForward() 
        end),
        TimeEvent(12*FRAMES, function(inst) PlayFootstep(inst) end),
        TimeEvent(14*FRAMES, function(inst) 
            PlayFootstep(inst)
            inst.components.locomotor:WalkForward()
        end),
    }
}, nil, true)
  • I have an inspectable creature but I can only highlight it (and chose to "examine" it) by hovering my mouse around a very small portion of its body, most of the creature being "unclickable". What could cause it and how to fix it? Messing with characterphysics value doesn't seem to affect it (which I beleive to be logical but still, just ruling that one out already).
  • How do you make your creature attackable? I have added the health component but the thing can't get hit. This is probably due to something extremely obvious
    inst:AddComponent("health")
    inst.components.health:SetMaxHealth(TUNING.PENGUIN_HEALTH)

 

It sould be noted that I currently have a creature that "works" and what I mean by that is that it has a brain that should make it able to wander and follow, it can only idle (there's not much else in the stategraph) and it actually appears visibly in the world. So it's really an idiot at this point, but at least it's got the bases. Also, all spriter animation has already been made so that's no problem either. Thank you :)

 

Edited by Thibooms
Link to comment
https://forums.kleientertainment.com/forums/topic/66514-questions-about-followers/
Share on other sites

For the creature being attackable, you need to add the combat component. For crafting your pet, you should look into shadowwaxwell.lua code as it does just that. for the walking you could do CommonStates.AddSimpleWalkStates(states, "walk") ("walk" being the animation name) which adds basic walking

1 hour ago, Aquaterion said:

For the creature being attackable, you need to add the combat component. For crafting your pet, you should look into shadowwaxwell.lua code as it does just that. for the walking you could do CommonStates.AddSimpleWalkStates(states, "walk") ("walk" being the animation name) which adds basic walking

Thanks! I'll look into that! :D

Always awesome to see how fast you reply :D!

@Aquaterion Ok, teacher, I've tried some things. The creature is now defitnely attackable so thanks for that (even though it's still difficult to click on)!

The walk animation defitnely works, but like the line suggests, it's verrry simple. I have actually made side and up animations. Do you happen to know how to use those as well? Knowing the creature is fourfaced (it says so in the prefab lua). Or is there some simple way to add "canrotate" to this? :)

Edited by Thibooms
3 minutes ago, Thibooms said:

@Aquaterion Ok, teacher, I've tried some things. The creature is now defitnely attackable so thanks for that (even though it's still difficult to click on)!

The walk animation defitnely works, but like the line suggests, it's verrry simple. I have actually made side and up animations. Do you happen to know how to use those as well? Knowing the creature is fourfaced (it says so in the prefab lua). Or is there some simple way to add "canrotate" to this? :)

How do you add the death animation? I have this in "local events" but the creature just slowly vanishes when dieing, instead of playing the animation :


    EventHandler("death", function(inst) inst.sg:GoToState("death") end),

 

for the death thing, do you have an actual state called "death", which plays a death animation?

for the walking stuff im checking i'll let you know if i figure something out

Just now, Aquaterion said:

for the death thing, do you have an actual state called "death", which plays a death animation?

No that was the problem, I fixed it right away and edited the post. Your page probably wasn't refreshed, sorry ^^'

Just now, Aquaterion said:

for the walking stuff im checking i'll let you know if i figure something out

Thanks, man :)

ok so if in local events = {} you add

 CommonHandlers.OnLocomote(false,true), --(canrun, canwalk)

 

when walking it will automatically call the state walk_start and walk_stop when it should stop,

i looked into some creatures and this seemed 1 of the simple ones

State{
		name = "walk_start",
		tags = {"moving", "canrotate"},
	    
		onenter = function(inst) 
			inst.components.locomotor:WalkForward()
			inst.AnimState:PlayAnimation("uranim_walk_pre") --im guessing you can just play the normal walk animation if u dont have a pre
		end,

		events=
		{   
			EventHandler("animover", function(inst) inst.sg:GoToState("walk") end ),  -- go to "walk" state, i think you can make it go to walk_start again and treat walk_start as walk as well.      
		},
	},

	State{
		name = "walk",
		tags = {"moving", "canrotate"},
	    
		onenter = function(inst) 
			inst.components.locomotor:WalkForward()
			inst.AnimState:PlayAnimation("uranim_walk_loop")
		end,
		
		timeline = 
		{
		    TimeEvent(0*FRAMES, PlayFootstep),--i think these are for sound?
		    TimeEvent(12*FRAMES, PlayFootstep),
		},
		
		events=
		{   
			EventHandler("animover", function(inst) inst.sg:GoToState("walk") end ),        
		},
	},
    
	State{
		name = "walk_stop",
		tags = {"canrotate"},
	    
		onenter = function(inst) 
			inst.Physics:Stop()
			inst.AnimState:PlayAnimation("uraim_walk_pst")
		end,
		
		events=
		{   
			EventHandler("animover", function(inst) inst.sg:GoToState("idle") end ), -- go to idle        
		},
	},

 

@Aquaterion

 

What should the animation layer names be when walking down, side and up? Right now, in my spriter I have

walk_loop_down

walk_loop_side

walk_loop_up

And I think there's a simple way to tell it "canrotate" (using tags like here I guess) and to play "walk_loop"

 

Do you know what I mean? By the way, I indeed don't have a pre or post animation (mainly because I never understood how they really work and seem overrated anyway) so I sadly don't know what to do with this code, because it's better not to tell it to do the regular animation when the game expects a pre/post animation ^^. 

 

If I could just do something like 

State{

        name = "walk",
        tags = {"moving", "canrotate"},

        -- Here is how we define what happens when we enter this state.
        onenter = function(inst)
            inst.components.locomotor:WalkForward()
            inst.AnimState:PlayAnimation("walk_loop")
        end,

    },

And then find a way to call the state properly, I think it would be allright, right? :)

Edited by Thibooms

I looked into some other creatures and the bees use this:

EventHandler("locomote", function(inst) 
        if not inst.sg:HasStateTag("busy") then
			local is_moving = inst.sg:HasStateTag("moving")
			local wants_to_move = inst.components.locomotor:WantsToMoveForward()
			if not inst.sg:HasStateTag("attack") and is_moving ~= wants_to_move then
				if wants_to_move then
					inst.sg:GoToState("premoving")-- change this to inst.sg:GoToState("walk")
				else
					inst.sg:GoToState("idle")
				end
			end
        end
    end),    
}

you could try it

@Aquaterion I'm afraid this only postpones the problem, by getting the creature to check if it's not being attacked to walk. It doesn't make the game recognize the "_down" "_side" and "_up" animations I have.

 

Do you know a way to implement those? Like telling it when walking sideways to use "walk_loop_side" and when walking downwards and upwards to use "walk_loop_down" and "walk_loop_up" respectively? :)

Just now, Thibooms said:

@Aquaterion I'm afraid this only postpones the problem, by getting the creature to check if it's not being attacked to walk. It doesn't make the game recognize the "_down" "_side" and "_up" animations I have.

 

Do you know a way to implement those? Like telling it when walking sideways to use "walk_loop_side" and when walking downwards and upwards to use "walk_loop_down" and "walk_loop_up" respectively? :)

no creature stategraph has that kind of implementation as it should be doing it automatically, are you sure you're calling "walk_loop" and not "walk"?

@Aquaterion I once made a chester clone and it does just that. I don't know how I got it working but this is the stategraph :

require("stategraphs/commonstates")

local actionhandlers = {}

local events=
{
    CommonHandlers.OnStep(),
    CommonHandlers.OnSleep(),
    CommonHandlers.OnLocomote(false,true),
    EventHandler("attacked", function(inst)
        if inst.components.health and not inst.components.health:IsDead() then
            inst.sg:GoToState("hit")
            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/hurt")
        end
    end),
    EventHandler("death", function(inst) inst.sg:GoToState("death") end),
}

local states=
{
    State{
        name = "idle",
        tags = {"idle", "canrotate"},
        
        onenter = function(inst, pushanim)
            inst.Physics:Stop()
            inst.AnimState:PlayAnimation("idle_loop")
            
            if not inst.sg.mem.pant_ducking or inst.sg:InNewState() then
                inst.sg.mem.pant_ducking = 1
            end
        end,
        
        events=
        {
            EventHandler("animover", function(inst) inst.sg:GoToState("idle") end),
        },

        timeline=
        {
            TimeEvent(7*FRAMES, function(inst) 
                inst.sg.mem.pant_ducking = inst.sg.mem.pant_ducking or 1
                inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/pant", nil, inst.sg.mem.pant_ducking) 
                if inst.sg.mem.pant_ducking and inst.sg.mem.pant_ducking > .35 then
                    inst.sg.mem.pant_ducking = inst.sg.mem.pant_ducking - .05
                end
            end),
        },        
   },
    State{
        name = "death",
        tags = {"busy"},
        
        onenter = function(inst)
            inst.components.container:Close()
            inst.components.container:DropEverything()
            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/death")
            inst.AnimState:PlayAnimation("death")
            inst.Physics:Stop()
            RemovePhysicsColliders(inst)            
        end,
    },
    State{
        name = "open",
        tags = {"busy", "open"},
        
        onenter = function(inst)
            inst.Physics:Stop()
            inst.components.sleeper:WakeUp()
            inst.AnimState:PlayAnimation("open")
        end,

        events=
        {   
            EventHandler("animover", function(inst) inst.sg:GoToState("open_idle") end ),
        },

        timeline=
        {
            TimeEvent(0*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/open") end),
        },        
    },

    State{
        name = "open_idle",
        tags = {"busy", "open"},
        
        onenter = function(inst)
            inst.AnimState:PlayAnimation("idle_loop_open")
            
            if not inst.sg.mem.pant_ducking or inst.sg:InNewState() then
                inst.sg.mem.pant_ducking = 1
            end
            
        end,

        events=
        {   
            EventHandler("animover", function(inst) inst.sg:GoToState("open_idle") end ),
        },

        timeline=
        {
        
        
            TimeEvent(3*FRAMES, function(inst) 
                inst.sg.mem.pant_ducking = inst.sg.mem.pant_ducking or 1
                inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/pant", nil, inst.sg.mem.pant_ducking) 
                if inst.sg.mem.pant_ducking and inst.sg.mem.pant_ducking > .35 then
                    inst.sg.mem.pant_ducking = inst.sg.mem.pant_ducking - .05
                end
            end),
        },        
    },

    State{
        name = "close",
        
        onenter = function(inst)
            inst.AnimState:PlayAnimation("closed")
        end,

        events=
        {   
            EventHandler("animover", function(inst) inst.sg:GoToState("idle") end ),
        },

        timeline=
        {
            TimeEvent(0*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/close") end),
        },        
    },
 }
 
 CommonStates.AddWalkStates(states, {
    walktimeline = 
    { 
        --TimeEvent(0*FRAMES, function(inst)  end),
        TimeEvent(1*FRAMES, function(inst) 
            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/boing")
            inst.components.locomotor:RunForward() 
        end),
        --TimeEvent(12*FRAMES, function(inst) PlayFootstep(inst) end),
        TimeEvent(14*FRAMES, function(inst) 
            PlayFootstep(inst)
            inst.components.locomotor:WalkForward()
        end),
    }
}, nil, true)

CommonStates.AddSleepStates(states,
{
    starttimeline = 
    {
        TimeEvent(0*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/close") end)
    },
    waketimeline = 
    {
        TimeEvent(0*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/open") end)
    },
})

CommonStates.AddSimpleState(states, "hit", "hit", {"busy"})

return StateGraph("picolo_lionel", states, events, "idle", actionhandlers)

And I always thought that the code that allowed the game to recognize my _down,_side and_up was this :

 CommonStates.AddWalkStates(states, {
    walktimeline = 
    { 
        --TimeEvent(0*FRAMES, function(inst)  end),
        TimeEvent(1*FRAMES, function(inst) 
            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/boing")
            inst.components.locomotor:RunForward() 
        end),
        --TimeEvent(12*FRAMES, function(inst) PlayFootstep(inst) end),
        TimeEvent(14*FRAMES, function(inst) 
            PlayFootstep(inst)
            inst.components.locomotor:WalkForward()
        end),
    }
}, nil, true)

But I have no idea how it really works. The TimeEvents that make the PlayFootstep fire seem to be for sound, so the only thing going on here is inst.components.locomotor:WalkForward. But that doesn't seem to fix my issue so I'm lost :/

2 minutes ago, Aquaterion said:

no creature stategraph has that kind of implementation as it should be doing it automatically, are you sure you're calling "walk_loop" and not "walk"?

Right, sorry, it's actually "idle_walk_down" "_side" and "_up"

Edited by Thibooms
3 minutes ago, Aquaterion said:

I mean all the things related to walkng in chester's are:


CommonHandlers.OnLocomote(false,true)

and the walktimeline thing, so did you try those 2 together and just them?

 

-- But then again, chester bounces, so it might work differently.

What I meant by chester clone was "a creature that acts like chester but that I designed and animated from scratch, the stategraph being made out of the combination of chester and an old mod". Sorry, I should've cleared that up ^^'

 

I don't see what there is to try, the bee's code simply brought me back to a walk state. I have to find a way to make the game understand what I want in that state, and I think it's something very simple I'm overlooking but I don't know what ^^'

Edited by Thibooms

@Aquaterion, yeah but here it is again, for the sake of simplicity :

I don't know which one you want so here's the creature that doesn't use the rotated animations :

--Stategraphs are used to present feedback to the player based on the state of the creature.  Here we setup two states,
--one to handle when the creature is idle and one to handle when the creature is running.

require("stategraphs/commonstates")

local actionhandlers = {}

local events=
{
    CommonHandlers.OnStep(),
    CommonHandlers.OnSleep(),
    CommonHandlers.OnLocomote(false,true), -- can run, can walk
    EventHandler("attacked", function(inst)
        if inst.components.health and not inst.components.health:IsDead() then
            inst.sg:GoToState("hit")
            -- inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/hurt")
        end
    end),
    EventHandler("death", function(inst) inst.sg:GoToState("death") end),
    EventHandler("locomote", function(inst) 
        if not inst.sg:HasStateTag("busy") then
            local is_moving = inst.sg:HasStateTag("moving")
            local wants_to_move = inst.components.locomotor:WantsToMoveForward()
            if not inst.sg:HasStateTag("attack") and is_moving ~= wants_to_move then
                if wants_to_move then
                    inst.sg:GoToState("walk")-- change this to inst.sg:GoToState("walk")
                else
                    inst.sg:GoToState("idle")
                end
            end
        end
    end),    

}

local states=
{
    --This handles the idle state.
    State{

        name = "idle",

        --Tags are how we can classify states.  The 'canrotate' tag tells the animation system that these animations can
        --be flipped based on which way the creature is facing which means we don't have to create multiple animations.
        tags = {"idle", "canrotate"},

        --Here is how we define what happens when we enter this state.
        onenter = function(inst, playanim)

            --In this case, all we want to do is play a looping version of the idle animation.
            inst.AnimState:PlayAnimation("idle", true)
        end,

    },

    State{

        name = "death",
        tags = {"death"},

        -- Here is how we define what happens when we enter this state.
        onenter = function(inst, playanim)
            inst.AnimState:PlayAnimation("death")
        end,

    },
    
    -- State{

        -- name = "walk",
        -- tags = {"moving", "canrotate"},

        -- Here is how we define what happens when we enter this state.
        -- onenter = function(inst)
            -- inst.components.locomotor:WalkForward()
            -- inst.AnimState:PlayAnimation("walk_loop")
        -- end,

    -- },
    
    
}

 CommonStates.AddSimpleWalkStates(states, "walk") -- Simple animation is simple :D

 -- CommonStates.AddWalkStates(states, {
    -- walktimeline = 
    -- { 
        -- TimeEvent(0*FRAMES, function(inst)  end),
        -- TimeEvent(1*FRAMES, function(inst) 
            -- inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/boing")
            -- inst.components.locomotor:RunForward() 
        -- end),
        -- TimeEvent(12*FRAMES, function(inst) PlayFootstep(inst) end),
        -- TimeEvent(14*FRAMES, function(inst) 
            -- PlayFootstep(inst)
            -- inst.components.locomotor:WalkForward()
        -- end),
    -- }
-- }, nil, true)

--Register our new stategraph and set the default state to 'idle'.
CommonStates.AddSimpleState(states, "hit", "hit", {"busy"})

return StateGraph("wurm_thibaud", states, events, "idle", actionhandlers)

 

And here 's the one for whom the rotated animations already work :

require("stategraphs/commonstates")

local actionhandlers = {}

local events=
{
    CommonHandlers.OnStep(),
    CommonHandlers.OnSleep(),
    CommonHandlers.OnLocomote(false,true),
    EventHandler("attacked", function(inst)
        if inst.components.health and not inst.components.health:IsDead() then
            inst.sg:GoToState("hit")
            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/hurt")
        end
    end),
    EventHandler("death", function(inst) inst.sg:GoToState("death") end),
}

local states=
{
    State{
        name = "idle",
        tags = {"idle", "canrotate"},
        
        onenter = function(inst, pushanim)
            inst.Physics:Stop()
            inst.AnimState:PlayAnimation("idle_loop")
            
            if not inst.sg.mem.pant_ducking or inst.sg:InNewState() then
                inst.sg.mem.pant_ducking = 1
            end
        end,
        
        events=
        {
            EventHandler("animover", function(inst) inst.sg:GoToState("idle") end),
        },

        timeline=
        {
            TimeEvent(7*FRAMES, function(inst) 
                inst.sg.mem.pant_ducking = inst.sg.mem.pant_ducking or 1
                inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/pant", nil, inst.sg.mem.pant_ducking) 
                if inst.sg.mem.pant_ducking and inst.sg.mem.pant_ducking > .35 then
                    inst.sg.mem.pant_ducking = inst.sg.mem.pant_ducking - .05
                end
            end),
        },        
   },
    State{
        name = "death",
        tags = {"busy"},
        
        onenter = function(inst)
            inst.components.container:Close()
            inst.components.container:DropEverything()
            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/death")
            inst.AnimState:PlayAnimation("death")
            inst.Physics:Stop()
            RemovePhysicsColliders(inst)            
        end,
    },
    State{
        name = "open",
        tags = {"busy", "open"},
        
        onenter = function(inst)
            inst.Physics:Stop()
            inst.components.sleeper:WakeUp()
            inst.AnimState:PlayAnimation("open")
        end,

        events=
        {   
            EventHandler("animover", function(inst) inst.sg:GoToState("open_idle") end ),
        },

        timeline=
        {
            TimeEvent(0*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/open") end),
        },        
    },

    State{
        name = "open_idle",
        tags = {"busy", "open"},
        
        onenter = function(inst)
            inst.AnimState:PlayAnimation("idle_loop_open")
            
            if not inst.sg.mem.pant_ducking or inst.sg:InNewState() then
                inst.sg.mem.pant_ducking = 1
            end
            
        end,

        events=
        {   
            EventHandler("animover", function(inst) inst.sg:GoToState("open_idle") end ),
        },

        timeline=
        {
        
        
            TimeEvent(3*FRAMES, function(inst) 
                inst.sg.mem.pant_ducking = inst.sg.mem.pant_ducking or 1
                inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/pant", nil, inst.sg.mem.pant_ducking) 
                if inst.sg.mem.pant_ducking and inst.sg.mem.pant_ducking > .35 then
                    inst.sg.mem.pant_ducking = inst.sg.mem.pant_ducking - .05
                end
            end),
        },        
    },

    State{
        name = "close",
        
        onenter = function(inst)
            inst.AnimState:PlayAnimation("closed")
        end,

        events=
        {   
            EventHandler("animover", function(inst) inst.sg:GoToState("idle") end ),
        },

        timeline=
        {
            TimeEvent(0*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/close") end),
        },        
    },
 }
 
 CommonStates.AddWalkStates(states, {
    walktimeline = 
    { 
        --TimeEvent(0*FRAMES, function(inst)  end),
        TimeEvent(1*FRAMES, function(inst) 
            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/boing")
            inst.components.locomotor:RunForward() 
        end),
        --TimeEvent(12*FRAMES, function(inst) PlayFootstep(inst) end),
        TimeEvent(14*FRAMES, function(inst) 
            PlayFootstep(inst)
            inst.components.locomotor:WalkForward()
        end),
    }
}, nil, true)

CommonStates.AddSleepStates(states,
{
    starttimeline = 
    {
        TimeEvent(0*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/close") end)
    },
    waketimeline = 
    {
        TimeEvent(0*FRAMES, function(inst) inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/open") end)
    },
})

CommonStates.AddSimpleState(states, "hit", "hit", {"busy"})

return StateGraph("picolo_lionel", states, events, "idle", actionhandlers)

Sorry I'm not using spoilers because right now every time I try it puts everything into one spoiler for some reason

Oh and by the way, the "chester" clone (so the above stategraph) also has idle rotated animation. I want to do the same with the new creature :)

 

 

 

 


--Stategraphs are used to present feedback to the player based on the state of the creature.  Here we setup two states,
--one to handle when the creature is idle and one to handle when the creature is running.

require("stategraphs/commonstates")

local actionhandlers = {}

local events=
{
    CommonHandlers.OnStep(),
    CommonHandlers.OnSleep(),
    --CommonHandlers.OnLocomote(false,true), -- can run, can walk
    EventHandler("attacked", function(inst)
        if inst.components.health and not inst.components.health:IsDead() then
            inst.sg:GoToState("hit")
            -- inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/hurt")
        end
    end),
    EventHandler("death", function(inst) inst.sg:GoToState("death") end),
    EventHandler("locomote", function(inst) 
        if not inst.sg:HasStateTag("busy") then
            local is_moving = inst.sg:HasStateTag("moving")
            local wants_to_move = inst.components.locomotor:WantsToMoveForward()
            if not inst.sg:HasStateTag("attack") and is_moving ~= wants_to_move then
                if wants_to_move then
                    inst.sg:GoToState("walk")-- change this to inst.sg:GoToState("walk")
                else
                    inst.sg:GoToState("idle")
                end
            end
        end
    end),    

}

local states=
{
    --This handles the idle state.
    State{

        name = "idle",

        --Tags are how we can classify states.  The 'canrotate' tag tells the animation system that these animations can
        --be flipped based on which way the creature is facing which means we don't have to create multiple animations.
        tags = {"idle", "canrotate"},

        --Here is how we define what happens when we enter this state.
        onenter = function(inst, playanim)

            --In this case, all we want to do is play a looping version of the idle animation.
            inst.AnimState:PlayAnimation("idle", true)
        end,

    },

    State{

        name = "death",
        tags = {"death"},

        -- Here is how we define what happens when we enter this state.
        onenter = function(inst, playanim)
            inst.AnimState:PlayAnimation("death")
        end,
    },
    
    State{

        name = "walk",
        tags = {"moving", "canrotate"},

        --Here is how we define what happens when we enter this state.
        onenter = function(inst)
            inst.components.locomotor:WalkForward()
            inst.AnimState:PlayAnimation("walk_loop")
        end,
		
		ontimeout = function(inst)
            inst.sg:GoToState("walk")
        end,
		
		events=
        {   
            EventHandler("animover", function(inst) inst.sg:GoToState("walk") end ),        
        },

    },
    
    
}

-- CommonStates.AddSimpleWalkStates(states, "walk") -- Simple animation is simple :D

 -- CommonStates.AddWalkStates(states, {
    -- walktimeline = 
    -- { 
        -- TimeEvent(0*FRAMES, function(inst)  end),
        -- TimeEvent(1*FRAMES, function(inst) 
            -- inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/boing")
            -- inst.components.locomotor:RunForward() 
        -- end),
        -- TimeEvent(12*FRAMES, function(inst) PlayFootstep(inst) end),
        -- TimeEvent(14*FRAMES, function(inst) 
            -- PlayFootstep(inst)
            -- inst.components.locomotor:WalkForward()
        -- end),
    -- }
-- }, nil, true)

--Register our new stategraph and set the default state to 'idle'.
CommonStates.AddSimpleState(states, "hit", "hit", {"busy"})

return StateGraph("wurm_thibaud", states, events, "idle", actionhandlers)

 

Can you try this out?

Edited by Aquaterion

@Aquaterion, you're awesome man! Thanks! :D

But I still don't understand what you exactly did x)

 

Oh and really just for your information (so just in case right), I did change the "walk_loop" to "idle_walk" because that's the way the rotated animations were named in Spriter.

Just now, Thibooms said:

@Aquaterion, you're awesome man! Thanks! :D

But I still don't understand what you exactly did x)

 

Oh and really just for your information (so just in case right), I did change the "walk_loop" to "idle_walk" because that's the way the rotated animations were named in Spriter.

I made it so the walk animation calls the walk animation again after its done, and you have 2 locomotor handlers at the top, so I removed 1 of em

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...