Line Of Sight with multiple enemies. Help!

Get help using Construct 2

Post » Sun Jul 28, 2013 9:07 pm

Hi!

How to use Line Of Sight behavior with multiple enemies? My enemy sprites have Platform behavior to control their movement.
For the enemy AI I've got something like this:

If Enemy has LOS to Player > Enemy simulate Platform pressing Right, Left, Jump, etc.

It all works fine with a single enemy but as soon as I create two or more enemies I start having this problem:

If Enemy #1 has LOS to player and simulates Platfrom pressing Right or Left then all other enemies do the same even if they don't have direct LOS to the player...

How to solve this problem?
B
12
S
2
G
1
Posts: 37
Reputation: 1,434

Post » Mon Jul 29, 2013 12:38 am

add a for each loop, so its like

"for each "enemy""
   >enemy has LOS to player > enemy simulate blah.

attach a .capx for more help, that is just my initial thought without much put into it.BACLog2013-07-29 00:39:01
B
25
S
7
G
1
Posts: 83
Reputation: 2,550

Post » Mon Jul 29, 2013 8:25 am

Yes, it works now with the For Loop! Thank you! But I'm still having one more problem:

If [Enemy] is [On Stopped] + [Overlapping Player] then play [Attack] sound

It works fine with a single enemy but, again, it doesn't work with multiple enemies. The For Loop isn't working here since there is a Trigger (On Stopped).

Any ideas on how to make each enemy play Attack sound as soon as they are close to the Player?

P.S. - I'm sorry but I can't send the .capx because it's a big project which is about to be released soon and I don't know if my people would like someone to have their project before them, you know.
B
12
S
2
G
1
Posts: 37
Reputation: 1,434

Post » Mon Jul 29, 2013 12:19 pm

I am recently having some troubles with LOS too. Shouldn't 'has Line of Sight' pick the object who has LOS without needing to go through a 'for each' loop? Like if you use 'on landed' for platform behaviour, it will only pick the instance that has landed, not all instances of that object.
B
28
S
8
G
5
Posts: 429
Reputation: 6,997


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests