Monte Posted January 4, 2017 Share Posted January 4, 2017 Hi All, It's my first time here, I have been playing around with LW for a while and just started to tinker with scripting, I have been modifying the monster ai script but have run into problems with the animation end hook call and need help to work out where I have gone wrong So when I use, self.baseAnimMgr:SetAnimationSequence(4, 0.03, 200) The animation plays fine but loops which is not what I want, so I'm trying to add the end hook using this, self.baseAnimMgr:SetAnimationSequence(4, 0.03, 200, 1,self,self.EndAttack) function Script:EndAttack() if self.state=="attack" then self.state="idle" end end I have already defined the "attack" state in triggering the animation, but, the end hook seems to trigger immediately so only a few frames of the anim plays and resets. Any Help much appreciated Quote Link to comment Share on other sites More sharing options...
Jazz Posted January 4, 2017 Share Posted January 4, 2017 Looks right to me. All I can suggest is playing with the animation speed (0.03) or using the new animation commands, PlayAnimation and StopAnimation. Quote --- Scott Using Windows 7 Ultimate 64 bit/Core I7-2700K @ 4312mhz/24G RAM/Nvidia GTX 1060 Link to comment Share on other sites More sharing options...
Monte Posted January 5, 2017 Author Share Posted January 5, 2017 Thanks SGB, I tried to use PlayAnimation and kept getting nil value errors so reverted back, I'm beginning to wonder if it is the part of the script these are placed that is the problem, I currently have call in function Script:UpdateWorld() and this function Script:EndAttack() if self.state=="attack" then self.state="idle" end end at the end of the script... Quote Link to comment Share on other sites More sharing options...
Jazz Posted January 5, 2017 Share Posted January 5, 2017 It may be stuck in attack mode calling the animation constantly. One-shot animations should only be called once. Adding System:Print("end animation") in your EndAttack function will show in the output window if it's getting called. You can try this script on the crawler prefab and see if it helps in any way. Script.mode = "idle" function Script:UpdateWorld() if window:MouseHit(2) then --play crawler attack animation self.mode = "attack" end if self.mode == "attack" then self.mode = "Waiting for animation to stop" self.entity:StopAnimation() self.entity:PlayAnimation("Attack2",0.009,10,1,"EndHit") elseif self.mode == "idle" then self.entity:PlayAnimation("Idle",0.02) end end function Script:EndHit() self.mode = "idle" end function Script:PostRender() context:SetBlendMode(Blend.Alpha) context:SetColor(1,1,1,1) context:DrawText("Mode: "..self.mode, 400, 200) context:SetBlendMode(Blend.Solid) end Quote --- Scott Using Windows 7 Ultimate 64 bit/Core I7-2700K @ 4312mhz/24G RAM/Nvidia GTX 1060 Link to comment Share on other sites More sharing options...
Monte Posted January 8, 2017 Author Share Posted January 8, 2017 Just wanted to say, Thanks SGB, Haven't got it correctly working yet but will keep going, Lua behaving very strangely. M Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.