Stop Pathfinding Objects Overlapping Each Other

0 favourites
  • 10 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I want to have a set of objects all going towards the same path, however the objects just overlap eachother, and when they follow another path they are all together.

    Here's an example of my problem: CAPX

    (just click to set a path)

    That example has me using the Solid behaviour, but it doesn't work.

    Any help would be greatful!

  • dl.dropboxusercontent.com/u/39000273/Maybe%20Fixed.capx

    I think you need to add Physics to your object...

    I am -not- an expert by any means but I do know that to keep Solids from overlapping that they have to have Collision detection which comes with Physics. At least that's how I understand it to work.

    I am assuming you're trying for a "follow-the-leader" kind of effect? I might consider using a "collision" trigger to stop movement. "Solid" is only one part of what you need I think!

    Physics gets tricky... good luck!

  • Well experimenting with the physics behaviour does stop them from overlapping, but they slide all over the place, not to mention it would mean applying physics to all the walls as well. :/

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Also trying the "On Collision" Trigger, it just stops both of the instances. Having them stop or even bounce back a few pixels would be great, but I cannot seem to access specific instances if I'm testing collisions of two of the exact same instances. :/

  • gamepopper

    Take a look at the RTS template.

  • This example was made for another question, but it shows you how you can get a hold of the instances if they are of the same type.

    .capx

    You can also do this:

    +Sprite1: On collision with Sprite1

       +System: Pick Sprite1 instance 0

          -> do something

       +System: Pick Sprite1 instance 1

          -> do something

    But here you have to know how many instances collide, or you could use it if you just want to pick one of them.

  • Try this, i was struggling with the same problem =)

    Push Out

    hope it helps. i think it's as best as you'll get without an external plug in.

    (also, check the RTS template example, It has a way to make objects maintain formation, which would make this look better)

  • spongehammer Sargas

    While the RTS method works, I'm working on a game that doesn't have the objects close in formation. The objects go towards a player, so if they are far away, they won't go near the player because they stay in formation.

    cvp

    I never realised you can pick out instances like that. I got a method that kinda sorta works like this:

    +Sprite1: On collision with Sprite1

       +System: Pick Sprite1 instance 0

          Move Forward 5 pixels

       +System: Pick Sprite1 instance 1

          Move Forward -5 pixels

    Everynow and then they go over each other but most of the time they don't.

    Sargas Your method does a good job, although I noticed some times the objects struggling to move when bunched together. :/

  • i'm sorry for replying without having anything to add to help you out,but i'll just tell ya your question is helping me as well ,still my sprites don't pump on each other quite as i want em to :

    also don't you just wish you could know the guy(s) who programed zergling AI to help us out:P?

  • also don't you just wish you could know the guy(s) who programed zergling AI to help us out:P?

    HAHA that would help. The annoying this is that I've had this problem with XNA, but I was able to solve it easily because I could access individual instances for calculations, for example:

    if (gameobject[x].isOverlapping(gameobject[y]) && x != y)

    {

       gameobject[x].X = gameobject[y].X + ((gameobject[x].width/2 + gameobject[y].width/2) * sin(angleBetween(gameobject[x], gameobject[y]));

       gameobject[x].Y = gameobject[y].Y + ((gameobject[x].height/2 + gameobject[y].height/2) * cos(angleBetween(gameobject[x], gameobject[y]));

    }

    This isn't the exact code I used, but it's very similar to what I had.

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