Switching to death animations (defiant enemies)

RPRP Member Posts: 1,990
edited March 2012 in Working with GS (Mac)
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.

Comments

  • LumpAppsLumpApps Member Posts: 2,881
    Try this:
    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
  • RPRP Member Posts: 1,990
    edited March 2012
    Cool, Let me try that out. Thanks @LudwigHeijden !

    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.






  • CloudsClouds Member Posts: 1,599
    When the flying actor is hit - spawn the explosion actor and destroy the flying actor.

    In the explosion actor place a rule that destroys it after however long you want to keep it on screen.

  • EatingMyHatEatingMyHat Member Posts: 1,246
    Just to add to @Tynan, try to move actors in and out of view instead of spawn and destroy (AKA recycle).


    Follow Eating My Hat on Facebook and the Blog
    Check out my templates in the GS Marketplace or at the store
  • CloudsClouds Member Posts: 1,599
    Just to add to @Tynan, try to move actors in and out of view instead of spawn and destroy (AKA recycle).
    Yep, if you have lots and lots of this kind of thing going on in one scene recycling the actors might be worth doing.
  • RPRP Member Posts: 1,990
    edited March 2012
    When the flying actor is hit - spawn the explosion actor and destroy the flying actor.

    In the explosion actor place a rule that destroys it after however long you want to keep it on screen.

    Oh hell, that makes sense. I was going to do that for enemies to drop items when killed, derp.
    Thanks @Tynan, let me give that a shot.

  • RPRP Member Posts: 1,990
    Just to add to @Tynan, try to move actors in and out of view instead of spawn and destroy (AKA recycle).


    Follow Eating My Hat on Facebook and the Blog
    Check out my templates in the GS Marketplace or at the store
    Yeah I'm having most enemies spawn outside the screen. Thanks guys!

  • RPRP Member Posts: 1,990
    That's the ticket!!! Thanks @Tynan !
    I'm going to go kick myself now for not thinking of that.
  • RPRP Member Posts: 1,990
    edited March 2012
    Just to add to @Tynan, try to move actors in and out of view instead of spawn and destroy (AKA recycle).


    Follow Eating My Hat on Facebook and the Blog
    Check out my templates in the GS Marketplace or at the store

    @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.


  • CloudsClouds Member Posts: 1,599
    edited March 2012
    Would you suggest using an interpolate behavior and turning the cannon fodder enemies invisible when hit, rather than destroying them
    For recycling simply stick in a change attribute - if you want something to disappear from the screen in an instant (without using destroy) then stick something like this on the actor:


    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.
Sign In or Register to comment.