Eusong Posted February 7, 2018 Share Posted February 7, 2018 (edited) I'm trying to get my creature, which walks on two legs, to get down on all fours before it starts sprinting. However, the animations for getting down and getting back up don't play. Here's my stategraph. Spoiler local states= { State{ name = "death", tags = { "busy" }, onenter = function(inst, playanim) inst.AnimState:PlayAnimation("death") inst.Physics:Stop() RemovePhysicsColliders(inst) end, }, State{ name = "idle", tags = {"idle", "canrotate"}, onenter = function(inst, playanim) inst.AnimState:PlayAnimation("idle", true) end, }, State{ name = "run", tags = {"run", "canrotate", "moving" }, onenter = function(inst, playanim) inst.AnimState:PlayAnimation("run_pre", false) inst.AnimState:PlayAnimation("run", true) inst.components.locomotor:RunForward() end, onexit = function(inst) inst.AnimState:PlayAnimation("run_pst", false) end, }, State{ name = "walk", tags = {"walk", "canrotate", "moving" }, onenter = function(inst, playanim) inst.AnimState:PlayAnimation("walk", true) inst.components.locomotor:WalkForward() end, }, State{ name = "yell", tags = {"yell", "canrotate", "moving"}, onenter = function(inst, playanim) inst.AnimState:PlayAnimation("attack") end, events= { EventHandler("animover", function (inst, data) . inst.sg:GoToState("run") end ), } }, State{ name = "hit", tags = { "busy" }, onenter = function(inst) inst.AnimState:PlayAnimation("hit") inst.Physics:Stop() end, events = { EventHandler("animover", function(inst) inst.sg:GoToState("idle") end), }, }, State{ name = "attack", tags = { "attack", "busy" }, onenter = function(inst, cb) inst.Physics:Stop() inst.components.combat:StartAttack() inst.AnimState:PlayAnimation("angry") end, timeline = { TimeEvent(15 * FRAMES, function(inst) inst.components.combat:DoAttack() end), }, events = { EventHandler("animover", function(inst) inst.sg:GoToState("idle") end), }, }, State{ name = "sleep", tags = { "busy", "sleeping", "nowake", "caninterrupt" }, onenter = function(inst) inst.components.locomotor:StopMoving() inst.AnimState:PushAnimation("sleep_pre", false) end, timeline = { TimeEvent(202*FRAMES, function(inst) inst.sg:RemoveStateTag("caninterrupt") end), }, events = { EventHandler("animqueueover", function(inst) if inst.AnimState:AnimDone() then inst.sg.statemem.continuesleeping = true inst.sg:GoToState(inst.sg.mem.sleeping and "sleeping" or "wake") end end), }, onexit = function(inst) if not inst.sg.statemem.continuesleeping then if inst.components.sleeper ~= nil and inst.components.sleeper:IsAsleep() then inst.components.sleeper:WakeUp() end end end, }, State{ name = "sleeping", tags = { "busy", "sleeping" }, onenter = function(inst) inst.AnimState:PlayAnimation("sleep") end, events = { EventHandler("animover", function(inst) if inst.AnimState:AnimDone() then inst.sg.statemem.continuesleeping = true inst.sg:GoToState("sleeping") end end), }, onexit = function(inst) if not inst.sg.statemem.continuesleeping then if inst.components.sleeper ~= nil and inst.components.sleeper:IsAsleep() then inst.components.sleeper:WakeUp() end end end, }, State{ name = "wake", tags = { "busy", "waking", "nosleep" }, onenter = function(inst) inst.components.locomotor:StopMoving() inst.AnimState:PlayAnimation("sleep_pst") if inst.components.sleeper ~= nil and inst.components.sleeper:IsAsleep() then inst.components.sleeper:WakeUp() end end, timeline = { CommonHandlers.OnNoSleepTimeEvent(26 * FRAMES, function(inst) inst.sg:RemoveStateTag("busy") inst.sg:RemoveStateTag("nosleep") end), }, events = { CommonHandlers.OnNoSleepAnimOver("idle"), }, onexit = function(inst) end, }, } local event_handlers= { CommonHandlers.OnSleepEx(), CommonHandlers.OnWakeEx(), CommonHandlers.OnFreeze(), EventHandler("locomote", function(inst) if not inst.sg:HasStateTag("busy") then if inst.components.locomotor:WantsToMoveForward() then if not inst.sg:HasStateTag("moving") then if inst.components.combat.target ~=nil then inst.sg:GoToState("run") else inst.sg:GoToState("walk") end end else if not inst.sg:HasStateTag("idle") then inst.sg:GoToState("idle") end end end end), EventHandler("attacked", function(inst) if not inst.components.health:IsDead() and not inst.sg:HasStateTag("busy") then inst.sg:GoToState("hit") end end), EventHandler("death", function(inst) inst.sg:GoToState("death") end), EventHandler("doattack", function(inst) if not (inst.sg:HasStateTag("busy") or inst.components.health:IsDead()) then inst.sg:GoToState("attack") end end), } CommonStates.AddFrozenStates(states) local function CleanupIfSleepInterrupted(inst) if not inst.sg.statemem.continuesleeping then end end return StateGraph("pikachu", states, event_handlers, "idle", {}) Â Â Edited February 7, 2018 by Eusong Link to comment https://forums.kleientertainment.com/forums/topic/87211-get-down-on-all-fours-animation-before-running-on-all-fours/ Share on other sites More sharing options...
pickleplayer Posted February 7, 2018 Share Posted February 7, 2018 Ah, I beleive what you are looking for in place of  "PlayAnimation("run", true)  is PushAnimation("run", true) pushing an animation means it will play when the animation before it finishes. If you just play it instead of pushing it, it doesn't matter which animation came before it, it'll just play right over it as if it was never there. Link to comment https://forums.kleientertainment.com/forums/topic/87211-get-down-on-all-fours-animation-before-running-on-all-fours/#findComment-1000636 Share on other sites More sharing options...
Eusong Posted February 7, 2018 Author Share Posted February 7, 2018 Thank you for replying! I tried what you suggested but now it's just invisible whenever it runs. Â Link to comment https://forums.kleientertainment.com/forums/topic/87211-get-down-on-all-fours-animation-before-running-on-all-fours/#findComment-1000739 Share on other sites More sharing options...
pickleplayer Posted February 7, 2018 Share Posted February 7, 2018 Woops, here, try this too Replace inst.AnimState:PlayAnimation("run_pre", false)  with just  inst.AnimState:PlayAnimation("run_pre") I don't think the "false" needs to be there. Or maybe it needs to be true, I don't remember off the top of me head, I'll look into it a little bit more later. Does it's run state work, by the way? As in, does it move around properly (excluding the animation bugs)? I don't think I've seen a run state set up like that before. Not that it wouldn't work, I'm just curious if a state that simple works well enough for a creature to move Link to comment https://forums.kleientertainment.com/forums/topic/87211-get-down-on-all-fours-animation-before-running-on-all-fours/#findComment-1000779 Share on other sites More sharing options...
Aquaterion Posted February 7, 2018 Share Posted February 7, 2018 47 minutes ago, pickleplayer said: Woops, here, try this too Replace inst.AnimState:PlayAnimation("run_pre", false)  with just  inst.AnimState:PlayAnimation("run_pre") I don't think the "false" needs to be there. Or maybe it needs to be true, I don't remember off the top of me head, I'll look into it a little bit more later. Does it's run state work, by the way? As in, does it move around properly (excluding the animation bugs)? I don't think I've seen a run state set up like that before. Not that it wouldn't work, I'm just curious if a state that simple works well enough for a creature to move the false/true is whether it should loop or not, by default its false, so doing that shouldn't change anything.  But you could check and make sure that the run_pre and run_pst animations exist in your build. store the spawned creature in a variable, and call the code what you normally would do on it; creature = c_spawn("PREFABNAME"); creature.AnimState:PlayAnimation("run_pre");  Link to comment https://forums.kleientertainment.com/forums/topic/87211-get-down-on-all-fours-animation-before-running-on-all-fours/#findComment-1000799 Share on other sites More sharing options...
Eusong Posted February 7, 2018 Author Share Posted February 7, 2018 (edited) Ah, it turns out I accidentally named the animations in the wrong order. (run_side_pre instead of run_pre_side, etc) So the animation plays for it getting down on all fours, but not getting back up. And yes, the creature does move while running. Edited February 7, 2018 by Eusong Link to comment https://forums.kleientertainment.com/forums/topic/87211-get-down-on-all-fours-animation-before-running-on-all-fours/#findComment-1000836 Share on other sites More sharing options...
Eusong Posted February 9, 2018 Author Share Posted February 9, 2018 Anyone? I'm still having trouble with this. Link to comment https://forums.kleientertainment.com/forums/topic/87211-get-down-on-all-fours-animation-before-running-on-all-fours/#findComment-1001771 Share on other sites More sharing options...
Aquaterion Posted February 9, 2018 Share Posted February 9, 2018 could be the same issue of push instead of play again. Your Walk/Idle might be overriding the run_pst animation Link to comment https://forums.kleientertainment.com/forums/topic/87211-get-down-on-all-fours-animation-before-running-on-all-fours/#findComment-1001786 Share on other sites More sharing options...
Eusong Posted February 9, 2018 Author Share Posted February 9, 2018 If that is the problem, I've tried everything I can think of to fix it and it still won't work. Link to comment https://forums.kleientertainment.com/forums/topic/87211-get-down-on-all-fours-animation-before-running-on-all-fours/#findComment-1001892 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now