How do I prevent enemies overlap each other using pathfinder

  • My enemies have the pathfinder behavior. It's working now, but they are passing over each other. So I set the obstacles as custom and then added them as obstacles on start of layout. However, it's not working and It keeps avoiding walls (solids) but not themselves.

    Would love some help here =/

    Thanks.

    edit: I know that I need to use regenerate obstacles action to update themselves as obstacles since they are moving, but then it starts to get really slow because its cpu intensive. How should I do? There are another way to make enemy's AI without pathfinder behavior?

  • Are the enemies Solids?

  • The best workaround is avoid the overlapping by using a checking overlapping procedure.

    It's simple, just make a condition "every tick" and "Enemy" is overlapping "Enemy Family", if so, then do an action "go to the opposite side" (you can do this last action by checking the angle of the overlapped enemy and adding 180 degrees in his direction of movement).

  • You could always do something custom. If they bump into each other, make them stop, shake their heads, take a step back, and find a new path You could even pick a random number to see what they do. Like if randomNumber = 1 they shake heads, step back, find a new path, if 2 they stand there looking like they're complaining to each other, 3 = they shake their fists at each other...

    Just some random examples, not sure what you're making though.

  • Well, I'd like to use pathfinder to solve this, but It seems that there are no way to make this without the high cpu cost

    Nice options, guys. I'll try them and see if it works.

    Thanks!

  • Well, none of these solutions worked that well =/. I tried regenerating just around those who is overlapping themselves but it doesnt work too.

  • TELLES0808

    I'm still trying to do it, but they got stuck and sometimes they go in the same direction when they have the same angle. Could you please make an example in capx for me?

  • Monday I'll take a time to make it for you =]

  • Monday I'll take a time to make it for you =]

    It's working ok now but thanks!

  • Monday I'll take a time to make it for you =]

    I'll take the example that's what I'm looking for...

    Thanks

  • scirra.com/forum/viewtopic.php

    It's nice. Thanks!

    Although, in your example, you are using an specific object and comparing with a family. Could you do the same but having just one family with several different objects? Because when you start to have several objects, pointing them specifically is not an option anymore. That's why I wanted to have one family (called Enemies for example) with several objects (ObjEnemy1, ObjEnemy2, ObjEnemy3....). The major problem is to get the objects of this family that is overlapping each other in a automatically way.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • kossglobal

    For that you could create two different families with the same object types in them.

  • kossglobal

    For that you could create two different families with the same object types in them.

    That's a tricky way to use families lol. But just adding the condition Family1.UID =/= Family2.UID would prevent from getting the same instance/object? I will test it. Thanks R0J0.

  • kossglobal

    Yeah, that should do it.

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