My enemies shots are sinchronized and I don't want that.

Get help using Construct 2

Post » Wed Feb 26, 2014 7:25 pm

I'm having a little problem when my enemies shoot me. They are shooting at the same time. The enemy that just entered the screen waits until the other one is able to shoot again and shoots together instead of shooting on his own.
Let me know if I wasn't clear.
The sinchronized shots I´m trying to avoid:
Image
The events related to them:
Image
B
3
Posts: 7
Reputation: 214

Post » Wed Feb 26, 2014 7:52 pm

Your problem is your last event, as every enemy is under the same "random" condition. You should instead use a Reloading boolean + a Wait(random).

Look at this example I made :
randomReloading.capx


You can toggle Line of Sight on enemies by clicking on them, as I didn't want to do the full game ^^
You do not have the required permissions to view the files attached to this post.
B
17
S
8
G
4
Posts: 473
Reputation: 6,221

Post » Wed Feb 26, 2014 7:56 pm

There are several ways of dealing with this.

First is that you can add a distance check, so only enemies that are within a certain range will attack.

You can do that by adding a for each and use Distance(X1,Y1,X2,Y2) and check the distance between the enemy and the player.

Another way could be to add a reload variable to your enemies, and whenever that is 0 it can shoot. But no matter what you need to add a For each, as of now you select all Enemies that meets these conditions. And since both enemies have line of sight to the player, and are selected with the "Is LOS = true" that will again trigger both.

Btw you don't need that variable The EnemyShooter -> Has LineOfSight to player already does that. So you could simply add that one instead of the variable.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Thu Feb 27, 2014 8:02 pm

Thanks guys! I will try what you told me to do and post again later! Thanks!
B
3
Posts: 7
Reputation: 214

Post » Thu Feb 27, 2014 8:54 pm

It's working! Thanks for everything!
Image
B
3
Posts: 7
Reputation: 214

Post » Thu Feb 27, 2014 9:25 pm

You may want to put the for each as the parent event and the other (on-screen, lineofsite, etc...) as subs to it so that it doesn't do all of those tests each time. May save you some computing cycles...
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,603

Post » Sat Mar 01, 2014 12:07 am

BluePhaze, thanks for the tip.
B
3
Posts: 7
Reputation: 214


Return to How do I....?

Who is online

Users browsing this forum: Bootfit and 14 guests