Spawn sprite on random enemy death

Get help using Construct 2

Post » Sun Oct 27, 2013 4:03 pm

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 :)
B
4
Posts: 12
Reputation: 251

Post » Sun Oct 27, 2013 4:05 pm

try using "for each" sprite > play death animation
B
23
S
3
G
6
Posts: 1,356
Reputation: 7,176

Post » Sun Oct 27, 2013 4:29 pm

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.
B
4
Posts: 12
Reputation: 251

Post » Sun Oct 27, 2013 4:55 pm


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)

:)

Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,592

Post » Sun Oct 27, 2013 5:19 pm

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

B
4
Posts: 12
Reputation: 251

Post » Sun Oct 27, 2013 9:10 pm

Apologies.. to the top!
B
4
Posts: 12
Reputation: 251

Post » Mon Oct 28, 2013 8:02 am

Hi there :)

change your random to random(2,4)


with random(2,3)    the 3 never falls
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,592

Post » Mon Oct 28, 2013 8:11 am

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Oct 28, 2013 8:50 am

[QUOTE=LittleStain] 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.. [/QUOTE]


Yup totally true,   

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

works well too

Various variations :)
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,592

Post » Mon Oct 28, 2013 9:39 am

Hi all,

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

Thanks
B
4
Posts: 12
Reputation: 251

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests