How do I make multiple enemies shoot at once?

Get help using Construct 2

Post » Sat Nov 12, 2016 7:35 pm

Message: Pixelpato can only post plain text URLS until they have 500 rep. 2 URLS modified. Why?
Hey guys,

right now I'm working on the enemy AI for my arcade top-down shooter. I have an enemy object with different behaviour states (handled by an instance variable: ivar_stance = 0,1,2,3). ivar_stance = 0 let the enemy chase you, ivar_stance = 1 let's him shoot you and so on. It's working fine until I spawn multiple enemies. Then every time the enemy is in shooting range (ivar_stance = 2 is active), only one of the spawned enemies is actually shooting at you. The funny thing is, all other events are working fine, just the bullet spawning for the enemy bullet doesn't seem to function.

Here is the event for the bullet spawning:
http://i.imgur.com/3f0Zwox.png

And here is the event that handles the behaviour states:
http://i.imgur.com/WzBnnq8.png

Can you help me out on this one? I'm searching a solution for a couple of days now =/
Last edited by Pixelpato on Sat Nov 12, 2016 10:09 pm, edited 5 times in total.
B
3
Posts: 5
Reputation: 185

Post » Sat Nov 12, 2016 8:31 pm

Probably an easy fix but those linked images are too small to see.
B
46
S
16
G
77
Posts: 2,155
Reputation: 45,823

Post » Sat Nov 12, 2016 9:51 pm

Yeah those are thumbnails.
@Pixelpato if you are using imgur, hover over the image and choose "Get share links", choose BBCode and remove the [img] tags.

Paste the resulting link into your post.


Btw, you probably only need to add a For each "enemy" condition to your bullet spawning conditions/events.
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Sat Nov 12, 2016 10:13 pm

@randomly
Thank you, I just uploaded the pics to imgur. I already implemented a "For each"-loop but this doesn't seem to function. All the actions in this loop function well for each enemy except the spawning of the bullets.
B
3
Posts: 5
Reputation: 185

Post » Sun Nov 13, 2016 3:02 pm

Add a "For each spr_enemy" where the mark is.
Image
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Tue Nov 15, 2016 10:19 pm

Just wanted to let you know, that I fixed the bug. It was the "Every 0.2 seconds" command that prevented the enemy bullets from spawning on multiple enemy objects.

Lesson learned: if you make a "Every X Seconds" command inside an "For each" loop it will not function for each object instance of this loop.

Thanks for your help nevertheless!
B
3
Posts: 5
Reputation: 185


Return to How do I....?

Who is online

Users browsing this forum: 25games, Artcadev, Ashley, mcscooter, Soluna Software and 27 guests