multiple enemies shooting bullets at the same time

Get help using Construct 2

Post » Wed Feb 24, 2016 8:11 pm

Hello!

I ran into a new problem.. I have multiple shooting enemies on the screen at the same time, but only one at a time is shooting.. If I kill the shooting enemy the next one will begin shooting

Screenshot:
Image

Code:
Image

You guys have an idea?
B
4
Posts: 12
Reputation: 224

Post » Wed Feb 24, 2016 8:41 pm

Add a "For each" (system condition) before the on-screen check
B
84
S
22
G
15
Posts: 1,039
Reputation: 15,249

Post » Wed Feb 24, 2016 8:55 pm

like this? does't work :( Still only one enemy is shooting and the others don't even start der shooting animation now :O

Image

Image
B
4
Posts: 12
Reputation: 224

Post » Wed Feb 24, 2016 9:10 pm

For each as subevent after 'System| every 1.0 seconds' or you could use instead of 'System| create object', 'Kanobär|Spawn Fireball ...', but then all of your sprites will fire at the same time.
If you don't want that use 'System| Pick a random instance -> System| Create object...' as subevent after 'System| every 1.0 seconds', that will randomly choose an instance that fire a fireball.
B
24
S
3
G
1
Posts: 451
Reputation: 2,165

Post » Wed Feb 24, 2016 9:27 pm

awesome! that works! you both rock <3

is there a way to let them shoot one after another?
B
4
Posts: 12
Reputation: 224

Post » Wed Feb 24, 2016 9:48 pm

Yes, its possible. The easiest is to use 'Pick nth Instance .'

Code: Select all
System| Every 1.5 seconds
    local static number x=0
    System| Pick kanobär instance x -> System| Create object Fireball on .....
                                    -> System| Add 1 to x
   
    System| x>= kanobär.count       ->System| Set x to 0


You don't have to use a local static variable you could also use a global
B
24
S
3
G
1
Posts: 451
Reputation: 2,165

Post » Wed Feb 24, 2016 10:00 pm

A timer behavior on your kanobär sprite would work great.

kanobär | On created -> Start timer "shoot" for 1.0 (Regular)
kanobär | On timer "shoot"
+kanobär | Is on-screen -> Your mirrored and not mirrored code as sub-events
B
69
S
28
G
24
Posts: 977
Reputation: 18,739


Return to How do I....?

Who is online

Users browsing this forum: newt and 6 guests