Solid Pathfinding

Get help using Construct 2

Post » Fri Mar 22, 2013 2:21 pm

I've been working with the new behavior and i need help with it.
Is there a way to make the object not overlap each other when there is a bunch of objects trying to move to the same space ?
B
6
Posts: 38
Reputation: 512

Post » Sun Apr 28, 2013 5:05 pm

Same question here! I'm working on my Ludum Dare project right now, so I hope I can get an answer asap!
B
21
S
6
G
3
Posts: 64
Reputation: 2,924

Post » Sun Apr 28, 2013 7:41 pm

Still can't figure it out.. is it a bug? :( Only a few hours left for the Ludum Dare, and this is an vital part of the game!
B
21
S
6
G
3
Posts: 64
Reputation: 2,924

Post » Sun Apr 28, 2013 8:08 pm

The behavior you asking for is actually very complex in practice. The best way I've found to do it is to use pathfinding for finding the path, then use physics for moving along the path by setting the velocity.

This creates some problems, though - like objects pushing other objects out of the way, so some objects can miss their nodes, and try to move backwards along the path to get back to them, and sometimes that involves moving through a wall and they get completely stuck, so then you need to keep the objects constantly checking for a path to their destination, but if you do it all at once on all instances every tick it can be too much CPU use and slam the framerate hard, so you have to cycle through the instances instead, only doing one per tick or such. Also there's the issue of what happens if the object can't get to a location because its already occupied by too many objects. To solve this I have the objects check how far they've moved in the past second, and if it's beneath a threshold, try to find a path again, and if that doesn't work, stop trying to move along the path.

Maybe there's a better way of doing it, but that's how I managed it.

However, if you only want them to not overlap when not moving rather than when moving, it's a ton easier. You could place a destination sprite at the mouse click and push it out of any objects, or you could give objects physics behavior, and disable collisions with other objects when it's moving along a path. Then when it stops moving, turn them back on again.Arima2013-04-28 20:26:46
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Sun Apr 28, 2013 8:37 pm

Thanks for your comment!

"The best way I've found to do it is to use pathfinding for finding the path, then use physics for moving along the path by setting the velocity."
Could you be more specific about this? How can I move the object along the path via a physics behaviour?
B
21
S
6
G
3
Posts: 64
Reputation: 2,924

Post » Thu Aug 08, 2013 5:14 pm

it seems everyone would love that path finding units could move without overlapping =/

I been struggling with this for almost a month now. has anyone come with a solution for this yet?
B
42
S
11
G
5
Posts: 446
Reputation: 6,417

Post » Thu Aug 08, 2013 5:23 pm

There are many different methods to set up movements for multiple objects, and that's part of the problem.
In particular the distribution, as in how far apart should the units be, are they in rows, and columns, or are they just there haphazardly?
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Thu Aug 08, 2013 6:55 pm

@newt

I think what we're asking here for is "the better solution" regardless of all the other possible options
B
42
S
11
G
5
Posts: 446
Reputation: 6,417

Post » Mon Aug 12, 2013 10:23 pm

The best Solution I found for now is:

Example:

Enemy is Overlapping AnotherEnemy.
Move Enemy 10 Pixels * Dt(Delta Time) in the Opposite Angle of the AnotherEnemy.

Not the best but solves a little bit.

Obs:. There is a System Expression that calculates the Angle between 2 points.

angle(x1, y1, x2, y2)

https://www.scirra.com/manual/126/system-expressions
B
13
S
3
G
1
Posts: 60
Reputation: 1,828

Post » Wed Dec 10, 2014 1:04 am

none of theses help me
B
5
Posts: 1
Reputation: 782

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 0 guests