Workaround to overcome a Box2D limitation?

Get help using Construct 2

Post » Sun Jan 27, 2013 5:08 pm

Hello all!
Since C2 uses Box2D for Physics and Box2D cannot disable collisions for single instances of an object type. I'm fff, well... not happy.

So far my only workaround to this is disable collisions and enable them as quick as the event ends. This makes my other instances loose their collisions but it's a matter of a second. But a second always can be seen...

Anybony discovered a method to, at least, fake a "not in collision" for a single instance with physics behavior enabled?

I will describe below my escene to make the picture:

* 4 instances of "player" with physic behavior (tiny masks)
* 1 instance of "enemy" with physics behavior (big mask)

Those are the mask of the actual characters and enemies but never mind.
The intention:
Move an instance of "player" across "enemy" mask sprite, through the other side.
While not affecting the other "players" instances on the same layout.

The normal behavior is to collide with the enemy at contact. And that fine, i need that too.
But I also need a way to cross an enemy (rising player z order) if some combination of imput is pressed (whatever input)

That is impossible with physics behavior active on both objects. They will bounce or all instances of the object type will be disabled while just one cross the enemy mask.

Big brains needed for this. (Just the crossing)
Thanks in advance!
B
31
S
4
G
4
Posts: 110
Reputation: 4,588

Post » Sun Jan 27, 2013 6:06 pm

Why not have 2 different sprites that use the same graphic. One that has physics and one that does not so you can pass through it. Just swap one for the other as needed.
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,418

Post » Sun Jan 27, 2013 8:02 pm

But for the time it takes to pass through the enemy it could be more troublesome to destroy a physics enabled object and recreate it once it crossed than just disable collisions and cross fingers. I'm reserving your idea for possible events that require longer periods of collisions or overlaps.

For how my characters moves (fast), they can cross a big enemy in 1 second or less. They move like bullets from point A to point B in stright line so i only need a second of collision inactivity without compromise other instances of the same type.

I have still no experience with "objects swapping", your method is fast an reliable enough?
Hillstrom2013-01-27 20:04:05
B
31
S
4
G
4
Posts: 110
Reputation: 4,588

Post » Mon Jan 28, 2013 2:49 pm

Im becoming old or old and stupid... It was just a matter of deactivating the "enemy_mask" object's Physics Collisions and let's the player's enabled. This crossing of enemies is only intended for big ones and thoose are limited to one, maybe two, at the same time. And that's more manageable than deactivating four fast moving charcaters collisions.

But, i'm still looking for any real or fake workaround to solve this "instance collision deactivation" issue.
B
31
S
4
G
4
Posts: 110
Reputation: 4,588

Post » Sat Apr 20, 2013 6:11 pm

You could work around by faking collisions instead, turn off all collisions, then instead have an event apply an impulse to an object.

This could then in turn be tied with a boolean or something so you got activated when needed, or not.

Image
B
27
S
9
G
5
Posts: 487
Reputation: 11,939


Return to How do I....?

Who is online

Users browsing this forum: Pandadoor, Sotir31, Yahoo [Bot] and 31 guests