Stop Pathfinding Objects Overlapping Each Other

Get help using Construct 2

Post » Fri Aug 02, 2013 1:47 am

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!gamepopper2013-08-02 01:48:47
B
24
S
5
G
1
Posts: 89
Reputation: 3,015

Post » Fri Aug 02, 2013 4:13 am

https://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!
B
10
S
4
G
2
Posts: 133
Reputation: 2,667

Post » Fri Aug 02, 2013 8:19 pm

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. :/
B
24
S
5
G
1
Posts: 89
Reputation: 3,015

Post » Fri Aug 02, 2013 10:37 pm

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. :/
B
24
S
5
G
1
Posts: 89
Reputation: 3,015

Post » Fri Aug 02, 2013 11:51 pm

@gamepopper

Take a look at the RTS template.
B
47
S
16
G
9
Posts: 1,097
Reputation: 11,180

Post » Sat Aug 03, 2013 12:04 am

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.
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Sat Aug 03, 2013 12:15 am

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)Sargas2013-08-03 00:28:21
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Post » Sat Aug 03, 2013 12:41 am

@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. :/
B
24
S
5
G
1
Posts: 89
Reputation: 3,015

Post » Sat Aug 03, 2013 1:48 am

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?
B
4
Posts: 24
Reputation: 248

Post » Sat Aug 03, 2013 11:24 pm

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

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.
B
24
S
5
G
1
Posts: 89
Reputation: 3,015

Next

Return to How do I....?

Who is online

Users browsing this forum: plinkie and 18 guests