How do I manage multiple enemies with Pathfinding

Get help using Construct 2

Post » Thu Nov 14, 2013 9:56 am

Hi everyone,

*** I'm new to the Forum and, as I already mentioned (in the wrong post), I wanted to thank the community who ask questions, answer and post capx for example. Sincerely, Thank you, I would have never achieved what I succeeded doing until now and I hope to get your knowledge in the near future to help others as well.***

I still need your help

Here is my problem:
I would like to create multiple enemies (same sprite and behavior) who have their own position on the map. When the Player gets into their range, only the enemy who detects the Player needs to chase him. If the Player manages to run outside of the detection range, the enemy returns to his initial position.

I can' post the link yet because I do not have enough rep :(
But if you really need the capx, change the "*" by "/" and "@" by "."
Sorry guys, it's a bit odd :(

The capx here:
https:"*""*"www"@"dropbox"@"com"*"s"*"obqkwbfzwrg2jvc"*"ForEachEnemy_DetectPlayer"@"capx

- The capx allows you to see how the Player moves toward Mouse clic with Pathfinding
- How an enemy detects the Player and chases him with Pathfinding
- On Attack Range, how the enemy triggers his attack animation
- If the Player manages to escape, enemies return to their position (I got lucky for this one.)

In addition, I would like to prevent enemies from overlapping each other when they attack the Player. Do you have any idea, suggestion for the approach to take? I'm thinking about changing my capx with the Turret/Line of Sight behavior and checking distance for the detection part. In addition, I think to add an array to check if enemies are not overlapping and if they do, move to another the closest free "array cell" from the Player. What do you think about this approach? Is there an easier way to get this?

Thanks
B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Thu Nov 14, 2013 11:58 am

" I would like to prevent enemies from overlapping each other when they attack the Player."

I currently have a similar problem ! I tried to set them as "solid" as well but it doesnt work, they don't "bounce" or avoid each other and they overlap.
B
8
S
4
Posts: 131
Reputation: 1,205

Post » Thu Nov 14, 2013 12:56 pm

Well, did you tried to workaround it by checking distances between each enemy? Or, simple check if an enemy overlapped another enemy and stop the pathfinder behavior?

It should be something like this:
= For Each Enemy ordered by UID (for example)
== Enemy_1 is NOT overlapping EnemiesFamily
---- Your pathfinder events here, including the event responsible for the enemy movement ----;

= ELSE
Stop Enemy (stop the pathfinder course too);
Image
B
108
S
24
G
18
Posts: 1,372
Reputation: 22,817

Post » Thu Nov 14, 2013 1:12 pm

Hi TELLES0808

Not yet, it is my next plan indeed :)
but I don't have Construct 2 license yet :( so, I can't work with families but I will get my license soon :)

B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Thu Jan 01, 2015 8:46 pm

hi TELLES0808, could u post a simple capx file...( iam beginner) and have exactly that problem
B
37
S
16
G
2
Posts: 447
Reputation: 4,865


Return to How do I....?

Who is online

Users browsing this forum: Elliott, kellehk, Voytek and 20 guests