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

Just started using Construct 2? Post your questions here

Post » Thu Jul 02, 2015 9:15 pm

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.
Risk Rocket now available on Google Play
Image
B
36
S
15
G
6
Posts: 337
Reputation: 6,300

Post » Thu Jul 02, 2015 9:35 pm

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

This will trigger 60% of the time.
ImageImageImage
B
71
S
22
G
247
Posts: 3,753
Reputation: 137,552

Post » Thu Jul 02, 2015 10:23 pm

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.
Risk Rocket now available on Google Play
Image
B
36
S
15
G
6
Posts: 337
Reputation: 6,300

Post » Thu Jul 02, 2015 11:03 pm

"On destroyed" is an event on the sprite. "Compare two values" is an event on System.
ImageImageImage
B
71
S
22
G
247
Posts: 3,753
Reputation: 137,552

Post » Sat Jul 04, 2015 5:50 am

Usman Haq wrote: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.
B
8
S
2
Posts: 35
Reputation: 572

Post » Tue Jul 07, 2015 5:22 am

Thanks guys. I'm a bit of a slow learner. Just implemented it, and it works perfectly.
Risk Rocket now available on Google Play
Image
B
36
S
15
G
6
Posts: 337
Reputation: 6,300


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests