Workaround to overcome a Box2D limitation?

0 favourites
  • 5 posts
  • 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!

  • 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.

  • 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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)