How do I stop sprites from overlapping each other?

Just started using Construct 2? Post your questions here

Post » Thu Dec 17, 2015 2:36 am

Hey, so is there a way to stop my sprites from overlapping each other? I have a basic platform ai that makes them case the player as it comes close enough, however since there are multiple enemies they all will run after the player and overlap with each other. I don't want this to happen. What can I do to stop this?

I considered making them solid, but that just is asking for problems since now I can jump on top of the enemies and thats not something that should happen. Also get stunlocked in between two enemies.
Last edited by littanana on Thu Dec 17, 2015 2:51 am, edited 1 time in total.
B
9
S
2
G
1
Posts: 51
Reputation: 823

Post » Thu Dec 17, 2015 2:43 am

What do you want them to do instead of overlapping, just stop? You could make use of loads of commands, you could use 'if enemy is overlapping player then stop moving', or 'overlapping at offset' if you don't want them to touch the player.
B
43
S
13
G
59
Posts: 1,779
Reputation: 35,731

Post » Thu Dec 17, 2015 2:50 am

I want them to not overlap. So basically, something like, the enemy that is on the left should move one pixel to the left and the one on the right should move one pixel to the right until they are no longer overlapping. I tried to make something like this happen, but the code just didn't work I always just get the sprites try and escape to the same direction. :I

I don't have problem with touching the player since they start an melee attack that stops them from running when they get close enough. But it just looks so silly when I have 3 enemies running and doing the same attack while overlapping with each other.

This is my latest failure: Image

Sorry if I was unclear in my first post, I don't have a problem with the player overlapping with the enemy I can fix that, but I have a problem with enemy overlapping with another enemy (which is the same sprite).
B
9
S
2
G
1
Posts: 51
Reputation: 823

Post » Thu Dec 17, 2015 12:30 pm

August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
63
S
32
G
39
Posts: 1,194
Reputation: 26,657

Post » Thu Dec 17, 2015 2:06 pm

I don't think this is the answer for my problem, also since my game is a platformer game, so I have no idea how to even implement that into my game based on that .capx

My idea to solve this would be to find a way to separate two of the same sprite which are overlapping, and I want the one on the left to move a pixel towards left, and the one on the right to move a pixel towards right. However, I have no idea how this can be done.

Here is my code if someone has an idea how to solve this on the AI moving code. (Basically it is just simple platformer ai code, move left if the player is left etc... so yeah...)

Code: Select all
https://drive.google.com/file/d/0Bw7sth_-pQTXUHRNQXhSUTdDMDA/view?usp=sharing
B
9
S
2
G
1
Posts: 51
Reputation: 823

Post » Mon Dec 21, 2015 10:36 pm

@littanana I too want to solve this. Usually if I try to make the overlapping enemies move left or right, they both move left or right together and keep going that direction. Does anyone else have any other ideas? Maybe pick the lowest UID?

Issue: Multiple enemies following player eventually clump up into a small ball rather than side by side. A good example of the desired effect is from Starcraft.
Check out my games on Google Play:

BEAST ATTACK (850,000+ downloads!)

ZOMBIE BASH (Android) (Launched Feb 17)

ZOMBIE BASH (iOS) (Launched March 17)
B
45
S
15
G
2
Posts: 425
Reputation: 5,035

Post » Tue Dec 22, 2015 3:38 am

Here is a really good example as well:
https://youtu.be/bovlsENv1g4?t=57s
Check out my games on Google Play:

BEAST ATTACK (850,000+ downloads!)

ZOMBIE BASH (Android) (Launched Feb 17)

ZOMBIE BASH (iOS) (Launched March 17)
B
45
S
15
G
2
Posts: 425
Reputation: 5,035

Post » Tue Dec 22, 2015 10:05 pm

Check out my games on Google Play:

BEAST ATTACK (850,000+ downloads!)

ZOMBIE BASH (Android) (Launched Feb 17)

ZOMBIE BASH (iOS) (Launched March 17)
B
45
S
15
G
2
Posts: 425
Reputation: 5,035


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest