Anyone did a pathfinder without colision?

Get help using Construct 2

Post » Mon Aug 08, 2016 3:28 pm

Hi, i need a pathfinder which will not have a collision without another pathfinder.
For example 2 zombies chasing a player but the zombie should not collide or overpass ( like solid )

Or how can i make such pathfinders ?
Thanks ;)
B
11
S
3
Posts: 277
Reputation: 1,395

Post » Mon Aug 08, 2016 10:27 pm

Do you mean they don't collide as in they avoid each other? Or take an alternate route if other zombie is already taking a route?
ImageImageImage
B
43
S
26
G
11
Posts: 516
Reputation: 10,473

Post » Mon Aug 08, 2016 10:50 pm

You might want to consider vector field collision avoidance. You can use it alongside existing pathfinding (if you're careful) to create the behaviour you describe.

Read more here:
buildnewgames.com/vector-field-collision-avoidance/
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,308

Post » Tue Aug 09, 2016 3:55 am

r0j0-039-s-experiments_t91829

You may also want to look into the first capx here. I recall there was a thread asking the exact same question a few months back but I forget how that turned out. I'll try digging it up.

Edit: how-do-i-add-span-class-posthilit-pathfinding-span-collision-with-c_p1056809?#p1056809 has another trick you can try.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,697
Reputation: 64,442

Post » Tue Aug 09, 2016 12:42 pm

@oosyrag
Thank you very much
B
11
S
3
Posts: 277
Reputation: 1,395

Post » Tue Aug 09, 2016 12:52 pm

@mrtumbles How can i do this ?
@badmoodtaylor I think that is the easy way but idk i will try it, i will come back!
B
11
S
3
Posts: 277
Reputation: 1,395

Post » Tue Aug 09, 2016 2:27 pm

@Radulepy I would create the vector field by pre-filling an array with vectors (which are number pairs describing a 2D direction and speed of movement).

For each zombie, find all zombies within whatever range you want them to avoid one another. For each one of these, compare its location (relative to the first zombie) to a location on the array, which will contain a vector. Add these vectors together, and apply them to the X and Y position of the first zombie, and they will all automagically avoid one another.

For more detailed description please see the link I posted above. It describes the process far better than I can.
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,308

Post » Tue Aug 09, 2016 2:31 pm

Another options is:

Zombie is overlapping Zombie
Pick top instance of Zombie
Zombie: Pathfinding: Set Speed to <decreased speed>

Might work well enough with some tweaking - although collision checks will suck if you're planning L4D/DR-style hordes :P
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,308

Post » Tue Aug 09, 2016 3:01 pm

This question gets asked a lot and I always link to the solutions in this thread :
viewtopic.php?f=147&t=171480&p=1033519&hilit=collision%2C+pathfinding#p1033519
B
47
S
17
G
81
Posts: 2,223
Reputation: 48,093

Post » Tue Aug 09, 2016 4:31 pm

Radulepy wrote:@badmoodtaylor I think that is the easy way but idk i will try it, i will come back!


I was actually asking a clarifying question. You say you don't want them to collide/overlap, which to me those are two separate things. Collide would be bouncing off each other where overlap does not. So I was asking if you wanted neither to happen and them to avoid each other in pathfinding.

One simple thought would to be make use of the pathfinding cost. So if after one instance choose a path add cost to that path to encourage others to choose a different path.

If your layout isn't too maze-like (not too many obstacles) I would think about ditching pathfinding behavior and make some events to avoid obstacles. Something as simple as pick nearest (obstacle) instance, if angle(player.x, player.y, obstacle.x, obstacle.y)-player.movement.angleofmovement is between -15 and 15 then alter the course could work.

These suggestions won't make the AI look as intelligent as some of the more elaborate suggested solutions. But you may want to take that into consideration, the intelligence of your enemy, when designing the AI for it. If low intelligence or making a goofy game you can have the object change course on collision even. If this is for a zombie wouldn't you rather have it running into stuff instead of flawlessly navigating a maze-like layout?
ImageImageImage
B
43
S
26
G
11
Posts: 516
Reputation: 10,473

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 45 guests