0 Favourites

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

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

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • 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.

  • "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)
Similar Topics Posts Views Last Post
Unread hot topic
167 14,484
DMT2005's avatar
DMT2005
Unread sticky
1 Favourites
C2 Games made with CocoonIO
136 89,806
minhcuong's avatar
minhcuong
Unread hot topic
99 10,124
karshinkoff's avatar
karshinkoff