Spawn sprite on random enemy death

  • Good afternoon all,

    i am currently trying to get a sprite to spawn on the death of an enemy, however i have 10 of the same enemy and i do not want the sprite spawning on the death of every enemy.

    is there any work around i can implement for this?

    Thanks in advance for any help :)

  • try using "for each" sprite > play death animation

  • Hi Draven,

    I may be interpreting this wrong, but im not sure this will execute the desired function.

    I have 10 monsters, i require the event sheet to spawn a sprite on the monsters death, but not every monster, this is the part im struggling with, have a random monster spawn the sprite.

  • set var -> var X = random(1,6)

    on destroy / death => spawn object   

    extra condition for on destroy: var X = 3

    There is now a 1 in 5 chance the spawn will happen, ... configure as desirable, with a global var, you can make it a level thing (auto increase or decrease etc)

    :)

  • Hi lennaert,

    i have tried to implement your solution, however it is not working.

    In the events sheet, i have the below set up ;

    Event 1 = Monster Health < or = 0 / Destroy

                                        Set PistolSpawn to Random(2,3)

    Event 2 =(condition 1)Monster on destroyed / Spawn Pistol on layer 0

            (condition 2)Pistolspawn = 3

    The instance variable is setup as a PistolSpawn, value starts at 0.

    Thank you for the help guys

  • Apologies.. to the top!

  • Hi there :)

    change your random to random(2,4)

    with random(2,3)    the 3 never falls

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It would be probably even better to use choose(2,3) instead of random here.

    If you do want to use random, make sure you use: floor(random(2,4)), for random(2,3) will never reach three and will give values inbetween 2 and 3 like 2,5678 when you really only want a value 2 or 3..

  • It would be probably even better to use choose(2,3) instead of random here.

    If you do want to use random, make sure you use: floor(random(2,4)), for random(2,3) will never reach three and will give values inbetween 2 and 3 like 2,5678 when you really only want a value 2 or 3..

    Yup totally true,   

    you could also int(random(1,4))

    works well too

    Various variations :)

  • Hi all,

    i am at work currently so i cannot test anything, no matter i appreciate every bodies help thus far.

    Thanks

  • > It would be probably even better to use choose(2,3) instead of random here.

    >

    > If you do want to use random, make sure you use: floor(random(2,4)), for random(2,3) will never reach three and will give values inbetween 2 and 3 like 2,5678 when you really only want a value 2 or 3..

    Yup totally true,   

    you could also int(random(1,4))

    works well too

    Various variations :)

    Hi all, int(random(1,4)) worked a charm.

    If possible can you advise what this solution is actually carrying out?

    Just so i know for future reference?

    Thanks all!

  • int turns the number that's between the brackets into an integer.

    in the manual under system expressions, you'll find more usefull expressions and what they do..

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