How do I stop instances of the same sprite from overlapping?

Just started using Construct 2? Post your questions here

Post » Thu Nov 17, 2016 7:15 am

Sorry for making 2 threads, just have another issue. I'm making a game where the player creates a copy of themselves from an item. It basically spawn another instance of the player's sprite. I just want to know a way to prevent the player's box from overlapping another instance of itself.
I had it setup something like this:

If Player.X < Player.X, then Set Player Platform vector X to -100. Obviously this isn't the correct solution, but still trying to figure this out.
B
12
S
2
Posts: 33
Reputation: 714

Post » Thu Nov 17, 2016 8:00 am

You could give the player sprites the "Solid" behavior. That should keep them from overlapping. Just make sure they don't spawn right on top of eachother.
B
20
S
6
G
4
Posts: 88
Reputation: 3,424

Post » Thu Nov 17, 2016 8:54 pm

I tried to make them solids, but the collisions started to act wonky.
B
12
S
2
Posts: 33
Reputation: 714

Post » Fri Nov 18, 2016 1:47 am

Use family and it's done with one event:
https://www.dropbox.com/s/4tjnro8xiy4j6 ... .capx?dl=0
Last edited by alextro on Thu Apr 06, 2017 3:11 pm, edited 1 time in total.
ImageImage
B
114
S
51
G
24
Posts: 790
Reputation: 23,480

Post » Fri Nov 25, 2016 2:31 am

@alextro Wow thanks for this! How did you figure this out btw? This has been a huge thorn in my side for awhile.
B
26
S
9
G
5
Posts: 24
Reputation: 3,485

Post » Fri Nov 25, 2016 1:10 pm

@ijust8
It is not too far from my previous example that push dragging object away; viewtopic.php?f=147&t=122964&p=877097&hilit=+drag#p877097

Kind of use similar technique with different situation. So little math is your friend.
ImageImage
B
114
S
51
G
24
Posts: 790
Reputation: 23,480


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests