One sided collisions

I came across this:

“preCollision”: an event type that fires right before the objects start to interact. Depending on your game logic, you may wish to detect this event and conditionally override the collision. For example, in a platform game, you may wish to construct “one-sided” platforms that the character can jump vertically through, but only in one direction. If you do not implement a “preCollision” listener, this event will not fire.

I can’t find any documentation that shows how to accomplish this. How do I use the preCollision event to override the collision so that my object will pass through the collided object on one side only? [import]uid: 8434 topic_id: 1920 reply_id: 301920[/import]

I really need to know how to do this. Please can someone from ansca reply with an example. [import]uid: 8434 topic_id: 1920 reply_id: 5690[/import]

So am I to assume the documentation for Game Edition is wrong and that this feature doesn’t exist? [import]uid: 8434 topic_id: 1920 reply_id: 5738[/import]

It’s been 4 days and I’m still waiting for ansca to reply. [import]uid: 8434 topic_id: 1920 reply_id: 5812[/import]

The one-sided platform is not a feature in itself, it’s a suggested possible use for the “preCollision” event. It’s actually a standard example suggested in the Box2D manual, but there are probably other uses.

In general, “preCollision” tells you that the objects are close but not yet interacting, so you can then choose to write some game logic. To override an impending collision, you could turn one of the objects into a sensor by setting object.isSensor = true, and to override an impending collision from one direction, you could first compare the object.y values of the platform and the figure to decide which side it’s coming from. That’s the general idea here. The logical flow would probably look like this:

  • Receive a “preCollision” event from the character/platform pair
  • Check relative vertical position of character
  • If character is approaching from below platform, set character to a sensor…
  • …and also set a timer of 1-2 seconds so the player has time to jump “through” the platform…
  • …then turn off the sensor property so the player interacts with solid objects again and “lands” on the platform.

Note that “close but not yet interacting” is a rather vague boundary, so you can get a LOT of “preCollision” events from the Box2D engine whenever things are sort of close to each other. For this reason, we advise using “preCollision” table listeners inside the specific objects you care about, rather than listening to “preCollision” in the global Runtime. [import]uid: 3007 topic_id: 1920 reply_id: 5879[/import]

preCollision has a bug in that it is being fired after the global ‘collision’ event. It is therefore rather useless. [import]uid: 21280 topic_id: 1920 reply_id: 26467[/import]

Has anyone been able to solve this precollision problem [import]uid: 41247 topic_id: 1920 reply_id: 29376[/import]