How do I make a object spawn randomly on death of enemy?

0 favourites
  • 6 posts
From the Asset Store
Give Sound to the enemies that are part of your game! :)
  • I want a object to spawn randomly on death of a enemy or if I can make it a little more common than random, how do I do it?

    In this case, there's multiple enemies on screen and they are constantly being killed. So I want to make it so an object is randomly dropped from them after their death.

  • Enemy: On destroyed

    -> Compare two values: random(0,100) < 60

    This will trigger 60% of the time.

  • Would this be a sub event? Since this happens after the enemy dies. I'm a bit confused on how to make this happen. Should I make two Global Variables, which is what you mean by Compare two variable?

    I apologize, I just need more clarification.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • "On destroyed" is an event on the sprite. "Compare two values" is an event on System.

  • Would this be a sub event? Since this happens after the enemy dies. I'm a bit confused on how to make this happen. Should I make two Global Variables, which is what you mean by Compare two variable?

    I apologize, I just need more clarification.

    Event: Enemy: On Destroyed.

    Sub Event: System: Compare two values: random(100) less than 60. Action: Enemy: Spawn Another Object

    So when an enemy is destroyed the sub event check is triggered. Then the game rolls a random number between 0 and 100 and if the number is less than 60 the check returns as true and the action following it runs. If the number is 60 or above the check returns as false and the action is not run.

    If you want to be able to change what the number is checked against you can create a global variable. Then your action becomes: Compare two values: random(100) less than GlobalVariableName.

  • Thanks guys. I'm a bit of a slow learner. Just implemented it, and it works perfectly.

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