Solid Pathfinding

0 favourites
  • 12 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • 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 ?

  • Same question here! I'm working on my Ludum Dare project right now, so I hope I can get an answer asap!

  • 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!

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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?

  • 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?

  • 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?

  • newt

    I think what we're asking here for is "the better solution" regardless of all the other possible options

  • 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)

    scirra.com/manual/126/system-expressions

  • none of theses help me

  • Any updates or anyone find a good solution?

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