How do I make an object "pathfind away" from another object

0 favourites
  • 11 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Hello,

    I am using the Ghostshooter tutorial to make some tests about a game with zombie hunting innocent civilians .

    I am using the Pathfind behavior and, when a zombie approach a civilian, I make the civilian run to an EscapePoint far from the zombie.

    BUT I want to civilian to do so... while avoiding the zombie, even if it's on the way to the furthest EscapePoint.

    So :

    1- I create ZombieArea around a zombie

    2- I make it solid

    3- I regenerate pathfinding obstacle around ZombieArea

    4- I make the civilian find path to the furthest EscapePoint

    5- I disable solid in the ZombieArea

    ... but it does not work at all, and the civilians keep on running into the ZombieArea... and the Zombie itself

    Can you see what's wrong with my system ?

    The capix is here : dropbox.com/s/lc0wc8ginccrbb5/PIB_v2b.capx

  • Talking about events 16 - 18. There is no 1 solution, because there are many problems.

    Lets list up the problems (those i see) , and see if you see how to fix them.

    1/ There is no zombie picked in event 15.

    2/ There is no system (preferable containers) that links a zombie to its ZombieArea. So, even if you picked the zombie, you can not pick its ZombieArea. Overlap condition will not help, because sometimes they are with 4 on almost the same place.

    3/ Since there is no ZombieArea picked (so it is an un-referenced object), the actions addressed to ZombieArea, work on all of them. So, each one is set to solid. And there will be an obstacle region generated around each ZombieArea. You can as well regenerate the whole obstacle map, and have them always solid, if you not gonna pick them.

    4/ The obstacle map is ready in the next tick. But you force them to find a path in the same tick. Before the obstacle map is ready. In event 16.

    5/ And the worst. There is only 1 obstacle map. Every time you send a human out to find a path, it considers the same obstacle map. Now. If you get it to work, then every time you mark a region on the obstaclemap as en obstacle, it stays an obstacle until you clear it. So, the way you do it, in some short time each cell in the obstacle map will be marked as an obstacle. See it as stamps you set.

  • Thanks for your advice. I tried to put it that way but it seems I got it wrong as they keep ignoring ZombieAreas

    Can you tell me where I made mistakes ?

    dropbox.com/s/gf3re5wgm135ays/PIB_v3.capx

  • Thank you very much, it helps a lot to understand how it is supposed to work

    I see that you made a timer called "follow", but I am not sure what it was made for ?

  • When it needs to follow a moving object with pathfinder, it needs to recalculate its path regular, but not every tick.

    It takes time to find a path, so, if its gonna search for a path every tick, it is looking for a new path before the previous one is calculated, hence it never gets to the point to actual be able to follow that path.

    Regularly means every so much time, the timer solves that for me. When the timer fires, it finds a new path to the moving object. The timer is also is a little bit random to try to make only 1 path find in 1 tick. Spread the work.

    Hope you looked at the visualised obstacle map. Not only for debug purpose, it also helps you to arrange the obstacles in the layout in a good way. How more accurate the obstacles align to the obstacle grid (set in the pathfinder property's) how nicer the paths and how faster they are found. Also, how more narrow the gates can be.

  • Yes, I've also noticed this debug. It will be useful, thanks again

  • Hello

    As I'm working on my project I can see a bug on the pathfind system you helped me to set : the game freezes if a civilian is trapped in a "diagonal street" (while it does not freeze if this civilian is trapped in a "straight street").

    Can you understand why ?

    https://www.dropbox.com/s/ddz6v5m0273uq ... .capx?dl=0

  • Try Construct 3

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

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

  • Hello,

    It seems I need your help again ^^

    There is something I don't understand in this example : https://www.dropbox.com/s/yqna70ofmlg0h ... .capx?dl=0

    When I try to add new obstacles on the way of Zombies ans Civilians, I use Add Obstacle and Regenerate Around.

    So can you explain to me WHY, when I add the obstacle PoliceBlockade (line 30), I just can't make it a pathfind obstacle... unless one Policeman (line 70) dies ??

    I don't see the link between policemen and obstacles in this script. If I put Policemen out of the layout, PoliceBlockade will never become an obstacle.

    And that's the same for the object "District".

    Do you see why ?

    thank you for your help <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    Mogador

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