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

Get help using Construct 2

Post » Sat Oct 29, 2016 8:06 pm

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 : https://www.dropbox.com/s/lc0wc8ginccrbb5/PIB_v2b.capx?dl=0
B
6
S
2
Posts: 30
Reputation: 571

Post » Sat Oct 29, 2016 11:24 pm

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.
B
33
S
18
G
27
Posts: 2,440
Reputation: 20,344

Post » Sun Oct 30, 2016 10:37 pm

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 ?

https://www.dropbox.com/s/gf3re5wgm135ays/PIB_v3.capx?dl=0
B
6
S
2
Posts: 30
Reputation: 571

Post » Tue Nov 01, 2016 9:15 pm

B
33
S
18
G
27
Posts: 2,440
Reputation: 20,344

Post » Wed Nov 02, 2016 10:13 pm

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 ?
B
6
S
2
Posts: 30
Reputation: 571

Post » Thu Nov 03, 2016 12:00 am

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.
B
33
S
18
G
27
Posts: 2,440
Reputation: 20,344

Post » Thu Nov 03, 2016 10:43 pm

Yes, I've also noticed this debug. It will be useful, thanks again :)
B
6
S
2
Posts: 30
Reputation: 571

Post » Sun Dec 18, 2016 5:46 pm

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
B
6
S
2
Posts: 30
Reputation: 571

Post » Sun Dec 18, 2016 10:22 pm

B
33
S
18
G
27
Posts: 2,440
Reputation: 20,344

Post » Mon Dec 19, 2016 8:41 pm

Thanks again :)
B
6
S
2
Posts: 30
Reputation: 571

Next

Return to How do I....?

Who is online

Users browsing this forum: davidbox, Mayfly and 5 guests