Switching to death animations (defiant enemies)
Hey there folks,
I have an issue I am running into when I kill my on-screen enemies. Each enemy has an individual animation. Their normal animation (4 frames) and their death (explosion of 7 frames). I had created 2 integer attributes, one for flying=0 and one for exploding=1.
I have a rule set up so that when the enemy collides with a bullet, it switches to the exploding animation. I have a timer set for .6 seconds to destroy the actor (enough time for the explosion to pass).
It works, but the issue is that 90% of the time the actor takes a hit and continues to stay on screen and can continue to receive multiple hits, triggering the explosion over and over until eventually he is destroyed. It is a one-hit one-kill set up, so he should blow up once he is hit and then disappear.
I find that when I play with the explosion animation FPS and the "death" timer, it does improve a bit, but still even with the restore actor options off the character still intermittently stays on screen for a second hit, or displays the actor in his fling state briefly before disappearing.
It's driving me bonkers. Going to take a break from it and see if you all have some suggestions for me before I jump in again.
I have an issue I am running into when I kill my on-screen enemies. Each enemy has an individual animation. Their normal animation (4 frames) and their death (explosion of 7 frames). I had created 2 integer attributes, one for flying=0 and one for exploding=1.
I have a rule set up so that when the enemy collides with a bullet, it switches to the exploding animation. I have a timer set for .6 seconds to destroy the actor (enough time for the explosion to pass).
It works, but the issue is that 90% of the time the actor takes a hit and continues to stay on screen and can continue to receive multiple hits, triggering the explosion over and over until eventually he is destroyed. It is a one-hit one-kill set up, so he should blow up once he is hit and then disappear.
I find that when I play with the explosion animation FPS and the "death" timer, it does improve a bit, but still even with the restore actor options off the character still intermittently stays on screen for a second hit, or displays the actor in his fling state briefly before disappearing.
It's driving me bonkers. Going to take a break from it and see if you all have some suggestions for me before I jump in again.
Comments
In the rule where you trigger the explosion you now have probably a condition when actor overlaps or collides with bullet.
Ad a second condition with the plus sign (make sure the when all is on) and do when attribute "HERE THE INTEGER ATTRIBUTE YOU USE FOR FLYING AND EXPLODING" = 0
Now the actor only explodes when hit by a bullet AND your attribute is 0
Hope this helps.
Cheers,
Ludwig
Lump Apps and My Assets
Edit: Alright back at my machine.
I'm not sure I understand what you are saying @LudwigHeijden, there would need to be two separate attributes for the two different states of animation.
Can you clarify?
My integer attributes for the actor: Flying =0, Explode =1
My Rule (when all):
Actor receives event: overlaps or collides: actor of type: (my bullet)
Attribute: self.Explode:=1
Animate (my animation)
Timer:0.6
Destroy this actor
I recall an old discussion that covered something similar, I'll see if I can find it as a resource.
In the explosion actor place a rule that destroys it after however long you want to keep it on screen.
Follow Eating My Hat on Facebook and the Blog
Check out my templates in the GS Marketplace or at the store
Thanks @Tynan, let me give that a shot.
I'm going to go kick myself now for not thinking of that.
@EatingMyHat Well, I'm going to have around 30 to 50 enemies that need to be destroyed before encountering the boss. I'll need to have 50 enemies dead = true, then the boss interpolates into the scene.
Would you suggest using an interpolate behavior and turning the cannon fodder enemies invisible when hit, rather than destroying them? How well does the interpolate behavior get along spawning actors? Or would would you need to use the change attribute behavior to recycle/randomize the start position of the actors in conjunction with the interpolate behavior? Not to sure how performance via spawn and destroy will be effected yet, it has been running smoothly so far.
When hit - change attribute - self.position X to -300
So when an actor is hit it is then kept off the screen for when you want to recycle it.