How to make enemies be solid to each other 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.
  • For the record, I based my project off of the included Turret Defense example.

    So there are Enemy Spawners, and every decreasing amount of time they spawn 6 enemies in a circle around them. Those enemies then Pathfind their way to the Player Core - whatever enters their Turret behavior's range stops them and makes them attack it.

    Now, after many trials and tribulations, I managed to do that, with one problem - enemies don't push other enemies around. They're solid. They have physics. The Turrets push each other around, so why can't the enemies?

    Here's the (probably) relevant piece of code.

    My guess is that the Enemy Pathfinding overrides everything else once it sets a path maybe? I dunno.

    -J.

  • The solution is in here somewhere

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The solution is in here somewhere

    I tried increasing the cell size & border, and changed the origin, and still no luck

  • Things i dont understand (cant run it, cant look at the debugger, just a screenshot)

    Tick 1.

    Right after creation there is a 'find path to PlayerCore' (ofcourse i have no idea what that is, i suppose the player's buildings are clusterd arround the core or something like that). Towers are the targets to find for the turrents. I have no idea if the LOS has obstacles attached.

    Then, (event 16) When enemy has not target, and its not moving on a path, pick the nearest tower to that enemy, and find a path to it. At this moment it is for sure not moving yet. It gets moving in the next event. I have ofcours no idea to know if it has a target. I think not. So right now, that condition is always true. It will never move on a path to the playercore. And now it is allready looking for a new path to the nearest tower.

    Next event you move its found path, when a path is found. But pathfinding takes TIME. If a path is found right now, in the same tick, like 0.00001 seconds after event 16, where it is set to look for a path, it moves on a path to the nearest tower. But, i doubt that this path is found allready. Finding a path takes TIME. How much depends on the complexety of the scene. I would not count on it having a path allready.

    Event 18. When it has a target and it is seeing the tower, stop moving. Can be ignored in this tick. Because i dont think the path is found allready. I also doubt that it has a target, it did't move yet.

    Next tick. Tick 2.

    It is not moving, it has no target (i cant see this, but i think so), so event 16 will let it again find a path to the nearest tower. Its is again calculating a new path. And that will probaly (i dont know how complex your scene is) again not be calculated and be ready for the next event. Where it is supposed to start moving.

    Not moving, so probaly no target.

    Next tick. Tick 3

    All over again.

    Some of this is wild guessing, i have to, it is only a screenshot. It cant be debugged. I cant watch it in action.

    But i hope you understand what i try to say.

    Also.

    Event 13 is a bit tricky. I would make a top event > enemy > 'on creation'. And bring all those actions there. But that is up to you.

    I suppose you use containers.

  • djohoe28 Is this the logic that you was looking for ?

    https://drive.google.com/open?id=0B1SSu ... DQ3MXNMUFE

    There are 3 major things you have to deal with.

    1/ there is only one obstaclemap for all

    2/ find a path & calculate obstacle maps take time

    3/ the calculated obstacle map is available in the NEX tick

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