specific animation has played a specific frame?
I am trying to determine if there is a condition to see if a specific animation has reached a specific frame? I am guessing I can use the expression calculator under "Compare current frame of XXX to a value" but I don't know the syntax for defining the animation by name. Anyone know if this is possible?
I am trying to make an enemy perform an action on a specific frame of an animation.
Re: specific animation has played a specific frame?
I'm an idiot. I figured it out.
But now I am stumped as to how I would make an animation repeat within a fastloop. I am trying something like this:
(On loop)
+set ID(Enemy) to Loop Index
+Is AltVar for Bullet Firing offset <= 0?
+Is animation "Shooting" playing?
+Is the frame # = 4
--->Create Bullet
--->(Bullet)Set Bullet Movement
--->(Bullet)Set Bullet Direction
--->(Bullet)Set AltVar for Bullet Firing offset to 25
--->(Enemy)Add 1 to Bullets Fired
--->(Enemy)Change Animation Sequence to Shooting
Basically, I want the Shooting animation to repeat every time the Bullet Firing offset reaches zero. I thought that setting the animation to Shooting as the last part of the sequence would do it, but it only plays the animation once and then holds the last frame while it shoots out the bullets every 25 loops.
Any ideas how I might fix this?
Mobichan
Re: specific animation has played a specific frame?
The above example seems to just play the Shooting animation once, then it automatically goes to the Stopped animation. Then it continues to spawn the bullets, but fails to repeat the shooting animation over and over. I was trying to use the "Change animation to Shooting" action to accomplish this, but the game seems to ignore it. Any ideas why?
Re: specific animation has played a specific frame?
Dumb question, but did you check you have the anims set correctly (the actual animation of shooting in the "shooting" and not in the "walking" or something)? Happened to me once. o^_^o;
Re: specific animation has played a specific frame?
Well, this looks kinda odd to me...
+Is animation "Shooting" playing?
--->(Enemy)Change Animation Sequence to Shooting
Re: specific animation has played a specific frame?
Try Resetting the animation before you start it again, sometimes if you start an animation the moment it has ended it gets stuck at the last frame...
Re: specific animation has played a specific frame?
Werbad: it is getting stuck on the last frame. But I don't know how to "reset" an animation within a fastloop. I thought every time it ran the loop, it would play the animation over and over when the condition is met. That is why I have the last action as "Change animation to Shooting."
It just seems to play the animation once, then continue the fastloop actions for spawning my bullets. I have the bullets working off a countdown on an alt var, so when it reaches 0, the bullet fires. Then it resets the counter and repeats until the total bullet count reaches a number. I basically wanted to reset the shooting animation every time the countdown reaches 0, but I guess my code isn't correct.
Ideally, I want the bullets to actually fire off when the countdown reaches zero AND when the animation is at a specific frame (frame 4, in this case). Then I want the shooting animation to repeat each time the fastloop countdown reaches 0 until the total number of bullets I have specified have reached a value.
I'm starting to confuse myself with this one. ^_^' Which Animation action would be ideal for resetting an animation? Or is the problem that I am trying to reset the action on the same line as the call to play it?
Re: specific animation has played a specific frame?
Here is the file in case anyone has time to take a look.
current project file
You can generate the enemy that uses the behavior I am working on with the RIGHT mouse button.
Re: specific animation has played a specific frame?
Re: specific animation has played a specific frame?
I took a look at your file but was not able to find a solution, maybe it's because there is too much code. But I know that there is a solution.
What I suggest you is to provide us with a stripped down version of your eventing. Then it will be easier for us to find the problem.
Also I noticed that at many places you are using loops where there's really no need to.
BTW nice graphics!
Re: specific animation has played a specific frame?
If I might ask, where do you feel I am using loops that are not necessary? Every time I use them, it is solely for the sake of giving objects unique ID's. If MMF2 handled objects uniquely, I probably wouldn't use fastloops at all. ;)
EDIT: Here is a stripped version... stripped file
Use LEFT mouse button to spawn the enemy in question.
Re: specific animation has played a specific frame
Okay I've modified your file and posted it. I've put red comments everywhere I've changed something:
http://www.clickteam.com/epicenter/ubbthreads.php?ubb=download&Number=2654
Maybe there is another way to achieve the desired result, but this is how I would do it.
First make the shooting animation to loop indefinitely with a loop back to the last frame. This is done in the Animation Editor.
Then instead of testing for "Animation Shooting is over" since the animation now won't stop anymore, test if "Animation Shooting is playing" and if "Current frame == 4".
Finally your actions remain the same, I've just added the 2 actions below to make the Shooting animation repeat:
Code:
- Ghoul: Force animation frame to 0
- Ghoul: Restore animation frame
The first action is pretty self explanatory, and the second one makes the animation play again with the speed set in the animation. Without the last action the animation would keep displaying frame 0.
About the loops. You shouldn't spread values and launch loops within the same event as this could lead to problems. I've also replaced all the "On loop" events by the same events without the loops as they are not needed.
In your case you don't need loops because you don't compare general values but you directly test for object values, so MMF does the object selection correctly.
Hope it helps! :)
Re: specific animation has played a specific frame
That is both awesome and worrying. I was under the impression that fastloops were necessary (from advice from others in the forum). And I was also under the impression that a spread value needed a fastloop. This is truly enlightening.
I understand everything in your example except one thing. You made frame 4 the frame that activates the next animation (turn around and fly away). I really want the last frame (frame 5) to play every time the bullet is spawned, but this looping method cuts off the final frame. I tried moving the force frame/restore actions to a new line under a "frame = 5" condition, but it seems to not work. Is it possible to force a frame once you are caught in a single frame loop (ie, once it reaches frame 5)?
Thanks for all the guidance,
Mobichan
Re: specific animation has played a specific frame
You shouldn't worry because grasping all the ins and outs of MMF can take some time. And this forum is your best ressource to grasp it all! :)
For some reason the frame numbers are 1-based in the Animation Editor, and 0-based in the Event Editor. So the last frame of your shooting animation is actually #4.
To solve your problem just duplicate the last frame of the shooting animation (now you have 6 frames) and test for "Current frame == 5" in the Event Editor. And don't forget to make the anim loop back to the last frame, referenced as #6 in the Animation Editor.
About the understanding of object selection I will quote Joshtek:
Quote:
Originally Posted by Joshtek
As far as object-picking is concerned, objects don't get picked by being referenced to in expressions en passim. They only get selected by meeting their own object conditions.
And some other interesting readings:
MMF Runtime, Object Selection and Fastloops
Getting the Most of..
Re: specific animation has played a specific frame
Oliver: Thanks for the heads up on the base-1 discrepancy. I read about that somewhere, but totally forgot when tinkering with this animation yesterday.
I'll also check out the reading. Everyday is a learning experience with MMF2. Even if I pull a little hair out... ;)
Re: specific animation has played a specific frame