Patriarachnid Posted February 6, 2015 Share Posted February 6, 2015 I am currently making a mod that adds some creatures built entirely from scratch. So far, everything's going peachy; the creature acts like it's supposed to, animates when it's supposed to, the whole nine yards. The only problem is that, when walking, the creature will only face right, never to the left, so it's often just walking backwards. I'm not sure what the problem is. The stategraph is working fine, the "canrotate" tag is added where it's supposed to, the brain is working, everything seems to be in order except for that one stupid thing. I've been working on this for a few days now, to no avail. Any ideas as to what the problem is? Link to comment Share on other sites More sharing options...
Corrosive Posted February 7, 2015 Share Posted February 7, 2015 I may be mistaken, but I believe the "canrotate" tag has to do with changing the movement direction in the middle of the animation. probably mistaken Does the creature use a different animation for up/down? If so is that working? Link to comment Share on other sites More sharing options...
Patriarachnid Posted February 7, 2015 Author Share Posted February 7, 2015 The creature does have different animation files for up and down, but visually they're identical to the side ones (it's a long worm creature, and perspective is hard). Just to test, though, I changed the up and down animations, and they did not work; the creature kept using just its facing-right walk animation.The creature does have different animation files for up and down, but visually they're identical to the side ones (it's a long worm creature, and perspective is hard). Just to test, though, I changed the up and down animations, and they did not work; the creature kept using just its facing-right walk animation. Link to comment Share on other sites More sharing options...
Corrosive Posted February 7, 2015 Share Posted February 7, 2015 That is interesting. If you're willing to attach (or send me directly if you are uncomfortable with that) files pertaining to the creature*, I'm more than happy to fiddle around with it to see if I can discern why that's happening. *compiled, as would be included in the finished product-- the .zip with the animations and the prefab/stategraph files Link to comment Share on other sites More sharing options...
Patriarachnid Posted February 7, 2015 Author Share Posted February 7, 2015 The stategraph:require("stategraphs/commonstates")local actionhandlers = {}local events={ CommonHandlers.OnStep(), CommonHandlers.OnLocomote(false,true), EventHandler("death", function(inst) inst.sg:GoToState("death") end), EventHandler("doattack", function(inst, data) if not inst.components.health:IsDead() and not inst.sg:HasStateTag("busy") and data and data.target then inst.sg:GoToState("attack", data.target) end end), EventHandler("attacked", function(inst) if not inst.components.health:IsDead() then if not inst.sg:HasStateTag("attack") then -- don't interrupt attack or exit shield inst.sg:GoToState("hit") -- can still attack end end 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("moving") else inst.sg:GoToState("idle") end end end end), }local states={ --This handles the idle state. State{ name = "idle", tags = {"idle", "canrotate"}, onenter = function(inst, playanim) inst.AnimState:PlayAnimation("idle", true) end, }, State{ name = "moving", tags = {"canrotate", "moving", "walk"}, onenter = function(inst) inst.components.locomotor:RunForward() inst.AnimState:PlayAnimation("walk", true) end, }, State{ name = "attack", tags = {"attack", "busy"}, onenter = function(inst, target) inst.Physics:Stop() inst.components.combat:StartAttack() inst.AnimState:PlayAnimation("atk") inst.sg.statemem.target = target end, timeline= { TimeEvent(25*FRAMES, function(inst) inst.components.combat:DoAttack(inst.sg.statemem.target) end), }, events= { EventHandler("animover", function(inst) inst.sg:GoToState("idle") 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 = "death", tags = {"busy"}, onenter = function(inst) inst.SoundEmitter:PlaySound(SoundPath(inst, "die")) inst.AnimState:PlayAnimation("death") inst.Physics:Stop() RemovePhysicsColliders(inst) inst.components.lootdropper:DropLoot(Vector3(inst.Transform:GetWorldPosition())) end, }, }return StateGraph("wormspider", states, events, "idle", actionhandlers)The brain:require "behaviours/follow"require "behaviours/wander"require "behaviours/chaseandattack"local WormspiderBrain = Class(Brain, function(self, inst) Brain._ctor(self, inst)end)local MIN_FOLLOW = 1local MAX_FOLLOW = 11local MED_FOLLOW = 5local MAX_WANDER_DIST = 12local MAX_CHASE_TIME = 10local function GetFaceTargetFn(inst) return inst.components.follower.leaderendlocal function KeepFaceTargetFn(inst, target) return inst.components.follower.leader == targetendfunction WormspiderBrain:OnStart() local root = PriorityNode( { ChaseAndAttack(self.inst, MAX_CHASE_TIME), Follow(self.inst, function() return self.inst.components.follower.leader end, MIN_FOLLOW, MED_FOLLOW, MAX_FOLLOW, true), --FaceEntity(self.inst, GetFaceTargetFn, KeepFaceTargetFn), Wander(self.inst, function() return Point(GetPlayer().Transform:GetWorldPosition()) end , MAX_WANDER_DIST) }, .5) self.bt = BT(self.inst, root) endreturn WormspiderBrainThe Spriter animation files are:atk_up / _side / _downwalk_up / _side / _downidledeathhit Link to comment Share on other sites More sharing options...
Corrosive Posted February 7, 2015 Share Posted February 7, 2015 In your initialization function, after you call inst.entity:AddTransform(), try calling inst.Transform:SetFourFaced(). Link to comment Share on other sites More sharing options...
Patriarachnid Posted February 7, 2015 Author Share Posted February 7, 2015 Oh, hey, that worked. Wow. How had I not seen that anywhere before? Thanks much. Oh, hey, that worked. Wow. How had I not seen that anywhere before? Thanks much. Link to comment Share on other sites More sharing options...
Patriarachnid Posted February 7, 2015 Author Share Posted February 7, 2015 Doublepost, doublepost. How do I forums, you guys? Link to comment Share on other sites More sharing options...
Digitalzer0 Posted December 17, 2015 Share Posted December 17, 2015 I am having the same issue. would you please post a shot of the fix and where it needs to be added? I am having the same issue. would you please post a shot of the fix and where it needs to be added? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.