Avoid overlaps without physics collision enabled ?

Get help using Construct 2

Post » Fri Jan 25, 2013 4:11 am

Hello all,
I have a problem that beats the hell out of me.

This is the escene:
4 character sprites (same object type) without physics are pinned each to 4 circular sprites with physics behavior.

I need to move those 4 pinned characters but without them bumping into each other. So, i turned off physics collisions for the circular sprites. Now those character sprites don't collide with each other.

But, i need them to not overlap to each other when i move them at low speeds or at bounces or unpredictable collisions with obstacles.
Two overlapped characters should separete to a minimum distance if they overlap at 0 speed or a low speed. But if a character moves fast it should still be able to "pass through" any character without any rearrangement.

It just the slow "after bounce" objects who should not stop one over the other.

Long explanation aside, How can i separate two overlapped characters (with physics) automatically? I tryed many things but i end with nothing good.

If someone need clarification or a capx i will post it.
But maybe it's a simple thing with a simple explanation.

Regards people!
B
31
S
4
G
4
Posts: 110
Reputation: 4,588

Post » Fri Jan 25, 2013 6:20 am

A collision check should do the trick, here is a demo:
Evil Sprites
You could adjust it to your environment, so you check for object speeds when collision happens etc.
B
24
S
8
G
7
Posts: 756
Reputation: 7,202

Post » Fri Jan 25, 2013 2:06 pm

The problem with your example @vee41 is that i need my sprites to not collide with each other only at low speed. Also they are pinned to another sprite with physics properties (behavior).
If i use collision checks they will bounce. And i need only stationary or slowly moving intance to be affected by the "no overlap" function/event.

Imagine a pool table, if i shoot a ball, it should "not" bounce against other balls. But, as this ball lose speed after some time, it should not overlap any other ball if it just stop to close and overlap one.

I guess i will need to add "speed" and "iddle" as instance variable of this objects. And filter by speed and iddle states.

But i'm failing in all my previos attemps.
B
31
S
4
G
4
Posts: 110
Reputation: 4,588

Post » Fri Jan 25, 2013 2:52 pm

My best shot so far is:
Objects:
CharMask = object with physic behavior

Event:
CharMask => Is Overlapping <CharMask>
|_CharMask => Is Sleeping    =>> CharMask => Apply Physics Force 40 at angle random(360)

It work fine for any instance of CharMask (previously ordered it's Z with a for each)
I will try to do the same for CharMask with velocity < something low. Just in case "sleeping" becomes unstable.

If someone found a better way please tell me.    
B
31
S
4
G
4
Posts: 110
Reputation: 4,588

Post » Fri Jan 25, 2013 4:00 pm

You could check for collision at offset (right in front of sprite) and if other object is detected you can disable collisions in case the speed condition is filled.

Or you could use the invisible collision sprite like you said yourself. It's probably your best bet. :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,202

Post » Fri Jan 25, 2013 4:23 pm

I updated my events this way:

Event:
CharMask => Is Overlapping <CharMask> ==> Sistem => Wait 1 sec
|__CharMask => Is Overlapping <CharMask> ==> CharMask => Apply Physics Force 40 at angle random(360)
   Is Sleeping

What i do was to check if the overlapping last more than 1 second. If it do Sleeping objects moves at a random angle.

So far is good. It do what i want. But maybe there's a better way. I'm interested in whatever optimization i can implement to this.
I will let this topic rest for a while and see if someone shows with an elegant solution.

Thanks vee41 for your help!
B
31
S
4
G
4
Posts: 110
Reputation: 4,588

Post » Thu Jan 01, 2015 8:14 pm

hi i have the same problem...can u post a simple capx file ?
B
28
S
11
G
2
Posts: 402
Reputation: 4,015

Post » Sun Jan 04, 2015 5:17 am

how about using distance() ?
"If you want to move a mountain tomorrow, you should start by lifting stones today."
B
47
S
11
G
2
Posts: 280
Reputation: 5,827


Return to How do I....?

Who is online

Users browsing this forum: h1k3, Unconnected and 1 guest