How to make enemies be solid to each other with Pathfinding?

Get help using Construct 2

Post » Wed May 25, 2016 10:37 pm

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.
Image

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

-J.
B
7
Posts: 11
Reputation: 283

Post » Wed May 25, 2016 10:42 pm

B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187

Post » Thu May 26, 2016 6:56 pm



I tried increasing the cell size & border, and changed the origin, and still no luck :(
B
7
Posts: 11
Reputation: 283

Post » Thu May 26, 2016 10:11 pm

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.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat May 28, 2016 9:01 pm

@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
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, ChesVCF, OBLIVION, shinkan, yiuyiu6666 and 25 guests