Testbed - OneSidedPlatform: unexpected results

This test is a bit confusing as it will not work if you rotate the "Platform".

E.g.
bd.angle = 0.5f;

Then you will unexpected results by the "Actor" which will fall through half way to the left. I find this to be not a good example of one sided platform.

What do you think?
If you rotate the platform, this check is no longer valid:

Code:
      if (position.y < m_top + m_radius - 3.0f * b2_linearSlop)
      {
         contact->SetEnabled(false);
      }


Can you figure out how to make this check more general and work for your scenario?
Erin Catto wrote:
If you rotate the platform, this check is no longer valid:

Code:
      if (position.y < m_top + m_radius - 3.0f * b2_linearSlop)
      {
         contact->SetEnabled(false);
      }


Can you figure out how to make this check more general and work for your scenario?


I find that check to be over engeneering. In a real game scenario an actor would be able to pass through a platform while moving upwards like in old-school/retro games. So while the actor is moving upwards, all contacts are disabled. But when the actor moves downwards, the contacts are enabled. Quite simple and elegant 🙂
That could be done with the linear velocity and contacts, so that the solution is still Box2D style.
Did you try it that way? I'd be happy to update the demo if you have something that works better.
You will get ugly result if you enable contacts when the actor start moving downward inside the platform.

This one works but I think the one in testbed is simpler if you only need horizontal platforms.
viewtopic.php?t=8146
AzureBlaze wrote:
You will get ugly result if you enable contacts when the actor start moving downward inside the platform.

This one works but I think the one in testbed is simpler if you only need horizontal platforms.
viewtopic.php?t=8146



Perhaps, it depends in the size of whatever that is in contact and how it's moving - but adding a threshold between contacts will solve that quickly!
Erin Catto wrote:
Did you try it that way? I'd be happy to update the demo if you have something that works better.



File attached.
I finally tried the velocity test. It seems to work well in isolation. However, if I pull down on the circle with the mouse joint I get a lot of jitter. This suggests the velocity approach may not work well when other bodies/joints interact with the character. Simple but perhaps too simple?
Erin Catto wrote:
I finally tried the velocity test. It seems to work well in isolation. However, if I pull down on the circle with the mouse joint I get a lot of jitter. This suggests the velocity approach may not work well when other bodies/joints interact with the character. Simple but perhaps too simple?


I always try to keep things simple 🙂 but of course more work is needed for "real" game scenarios. Which depends on the level of complexity in a game.
This is an alternative, I thinks it's always good to show different ways to do things.
Well I think you miss the point of the testbed. The main purpose is to demonstrate how to use the API and to test built-in functionality. How you implement game logic, like a one-sided platform, is up to you. I agree that there may not be one best way to handle a one-sided platform in Box2D, and I never claimed there was.

So this discussion really doesn't fit in this sub-forum because it is about game play choices. For those choices, we really need the context of your game.

Original thread: https://box2d.org/forum/viewtopic.php?t=8164