How do I manage multiple enemies with Pathfinding

0 favourites
  • 5 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • " 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.

  • 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);

  • 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 :)

  • hi TELLES0808, could u post a simple capx file...( iam beginner) and have exactly that problem

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)