Animation stuck while holding a fire button.
I can't get this to work properly.
I'm trying to get an animation in this way:
+ Repeat while Pressed fire 1
> Set "Animation Value" of "Sprite" = 1
+ NOT Repeat while Pressed fire 1
> Set "Animation Value" of "Sprite" = 0
+ "Animation Value" of "Sprite" = 1
> Change animation of "Sprite" to "TestAnimation"
+ "Animation Value" of "Sprite" = 0
> Change animation of "Sprite" to "Stopped"
But all I get is just a static first frame.
That's weird, because I'm using this same technique with the "Walking" animation, but pressing a direction instead of pressing a Fire button, and it works perfectly.
And yes, the new animation is configured with a correct min/max speed and looping enabled.
Is there a solution to this?
Thanks!
Re: Animation stuck while holding a fire button.
I think you could add conditions to your "Animation Value = ..." events to check if the animation you want is already playing before trying to change it... not sure, though.
Re: Animation stuck while holding a fire button.
Here is your problem, he is repeating the animation over and over from the beginning so fast that it never gets to the next frame! Add "+One condition when event loops" to the top condition
Re: Animation stuck while holding a fire button.
I already tried that, Skeets.
I really don't know why it works only with directional buttons, but not with fire buttons.
@DavidN:
That's definitely not it, thanks anyway!
Re: Animation stuck while holding a fire button.
Oh!! I got it. add "only one action when event loops" on the one with the set animation to test animation.
Re: Animation stuck while holding a fire button.
That doesn't work either, Skeets.
That just causes to show the first frame of the animation for less than a second.
---Later---
Ok I solved it!
Instead of making the code all nice and simple like I was trying to do it, I had to use many conditions and many OR instances, and absolutely no use of Variables to trigger the animations.
It's kind of messy, but it works exactly how I wanted to!
Re: Animation stuck while holding a fire button.
I am having a similar issue to yours it sounds like. Do you think you could post your solution?
I'm simply trying to set an animation (attack) for an enemy when they're within a certain range of the player, and when that animation is done it sets the animation back to their running anim. When ever I set the attack anim it only displays the first frame of the animation for the duration the full animation should take to play, and then returns to the running one. Here is the code that causes that -
npcState=ALERT
+npcSeePlayer=YES
+npcOnFloor=YES
+npcOnEdge=NO
+X position of npc >=X(player)-192
+npcCombatState=1
--- Change animation sequence to Attack
*and then later*
animation Attack is over
--- Change animation sequence to Running
After reading this post I added the "only once per loop" condition. However like someone mentioned above that causes the animation to flicker to the first frame quickly and then switch back to the Running animation. I've tried multiple animations in the place of "Attack", and I've tried adjusting the speed of its playback, but nothing seems to work.
Any help is appreciated!
Re: Animation stuck while holding a fire button.
So was it pretty much just adding "If animation X is NOT playing" to the event where it changes the animation, and copy pasting the event except changing "If animation X is playing" plus removing the part where it changes the animation?
Taking artician's case, like so:
npcState=ALERT
+npcSeePlayer=YES
+npcOnFloor=YES
+npcOnEdge=NO
+X position of npc >=X(player)-192
+npcCombatState=1
+animation sequence Attack is NOT playing
--- Change animation sequence to Attack
npcState=ALERT
+npcSeePlayer=YES
+npcOnFloor=YES
+npcOnEdge=NO
+X position of npc >=X(player)-192
+npcCombatState=1
+animation sequence Attack is playing
--- Any other actions regarding attacking (if not in another event altogether)
Re: Animation stuck while holding a fire button.
Thanks for the reply. I tried this, and a couple variations of it, but nothing changed. :(
Re: Animation stuck while holding a fire button.
Do you have any other events that make the enemy start running? It may be fighting with these guys over which animation is to be played.
If it's attached to an event that makes the enemy start moving towards the player, try adding the "animation sequence Attack isn't playing" to it.
Re: Animation stuck while holding a fire button.
I don't think it's fighting over the Run/Attack animation, but it attached to a sequence that controls the enemies movement as well. I tried to make the Attacking state of the enemies overrule the Running-around states, so if this isn't a common problem some people have had I will look at my code again.
Thank you!