Fade Out and Destroy - HP issue ?

0 favourites
  • 4 posts
  • Hey All,

    I have some crates on my level, and first I what I did was:

    After few hits (from the player) a crate will break.

    Once the break animation is finished, Destroy the Crate.

    It was easy and it works great!

    So I wanted to make it better using a nice fade-out and then destroy.

    But I had some issues, the first issue the Animation of the "BREAK" looped all the time (it's playing 1 on the animation editor, not on loop).

    I guess the reason for this is because the HP of the Crate, it's stuck on 0 so it keeps playing.

    When I played with "only once" it worked but then a different problem comes in.

    It will only destroy 2 or 3 crates, then the rest of the crates will never be able to break.

    Again... I'm sure it's something about the HP which is not for each crate but for all of them.

    My 2 failed attempts:

    BTW - Destroy is Enable on the properties for automatic destory when fade is finished.

    How can I make this work properly?

    Thanks ahead!

  • You have all the correct events, but they are in wrong places.

    First event should have two conditions:

    Crate HP<=0 : Crate start animation "Break"

    Trigger once

    Second event should also be top-level (not a sub-event):

    Crate on animation "Break" finished : Start fade

    However, this code may not work correctly if you have multiple instances of Crate object, because "Trigger once" doesn't work per instance. As long as one crate has HP<0, this event will not get triggered for other crates.

    So I suggest you change your code to this:

    Crate HP<=0                                : Crate start animation "Break"
    Crate animation "Break" NOT playing
    
    Crate on animation "Break" finished        : Start fade
    [/code:1rihlvf3]
  • Thank you very much dop2000,

    The second code was exactly what I needed for multiple crates.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • huum

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)