Pushing overlapping objects away from each other

Get help using Construct 2

Post » Sun Jul 28, 2013 12:16 am


Hey all, I got Construct 2 a week ago when it was on sale and I'm really digging it, it's very intuitive. However, I'm a bit stuck.

I have this enemy (Platform type) that I've made to chase the player along the ground. The probably is that they always end up overlapping each other and forming this bothersome singular mass.

Is there a way via the events to push them apart? I want to avoid using the solid behavior if possible because I still want the player to be able to pass through them, and the enemy pass through each other in certain situations.

Any help is appreciated.

Edit: Solved, see belowthinkTank2013-07-28 02:02:19
B
2
Posts: 3
Reputation: 156

Post » Sun Jul 28, 2013 12:55 am

Try something like this:
Object1 is overlapping Object2 and
Object1.x < Object2.x, then
set X of Object1 to Object1.x-1

This basically moves object1 to the left (if its on the left side) every moment it's overlapping object2. You can do it for the other side (and should) by changing the negative 1 to a positive 1 and the less than to a greater than.
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

Post » Sun Jul 28, 2013 1:05 am

What if they're of the same object?
B
2
Posts: 3
Reputation: 156

Post » Sun Jul 28, 2013 1:52 am

Okay, I got saw your other thread and did some experimenting.

Solution:

Put the Enemy in an Family (EnemyGroup)

For each Enemy
      Enemy is overlapping EnemyGroup
            If EnemyGroup.X < Enemy.X then self.platform.vectorX + 100
            If EnemyGroup.X > Enemy.X then self.platform.vectorX - 100

Thank you very much for your help
                  thinkTank2013-07-28 01:56:52
B
2
Posts: 3
Reputation: 156


Return to How do I....?

Who is online

Users browsing this forum: Congrats2u, vino7733 and 26 guests