# Box2D Forums

 It is currently Wed May 22, 2013 11:35 am

 All times are UTC - 8 hours [ DST ]

 Page 1 of 2 [ 11 posts ] Go to page 1, 2  Next
 Print view Previous topic | Next topic
Author Message
 Post subject: Testbed - OneSidedPlatform: unexpected resultsPosted: Fri Feb 10, 2012 6:31 am

Joined: Fri Feb 10, 2012 4:08 am
Posts: 11
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?

Top

 Post subject: Re: Testbed - OneSidedPlatform: unexpected resultsPosted: Fri Feb 24, 2012 4:51 pm

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
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?

Top

 Post subject: Re: Testbed - OneSidedPlatform: unexpected resultsPosted: Fri Feb 24, 2012 6:20 pm

Joined: Fri Feb 10, 2012 4:08 am
Posts: 11
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.

Top

 Post subject: Re: Testbed - OneSidedPlatform: unexpected resultsPosted: Tue Feb 28, 2012 2:24 pm

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
Did you try it that way? I'd be happy to update the demo if you have something that works better.

Top

 Post subject: Re: Testbed - OneSidedPlatform: unexpected resultsPosted: Tue Feb 28, 2012 9:47 pm

Joined: Mon Apr 11, 2011 1:57 am
Posts: 4
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

Top

 Post subject: Re: Testbed - OneSidedPlatform: unexpected resultsPosted: Tue Mar 06, 2012 11:55 am

Joined: Fri Feb 10, 2012 4:08 am
Posts: 11
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!

Last edited by BoxMan on Tue Mar 06, 2012 12:00 pm, edited 1 time in total.

Top

 Post subject: Re: Testbed - OneSidedPlatform: unexpected resultsPosted: Tue Mar 06, 2012 11:57 am

Joined: Fri Feb 10, 2012 4:08 am
Posts: 11
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.

Top

 Post subject: Re: Testbed - OneSidedPlatform: unexpected resultsPosted: Sun Mar 18, 2012 12:22 am

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
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?

Top

 Post subject: Re: Testbed - OneSidedPlatform: unexpected resultsPosted: Sun Mar 18, 2012 3:50 am

Joined: Fri Feb 10, 2012 4:08 am
Posts: 11
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.

Top

 Post subject: Re: Testbed - OneSidedPlatform: unexpected resultsPosted: Sun Mar 18, 2012 10:49 am

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
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.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 2 [ 11 posts ] Go to page 1, 2  Next

 All times are UTC - 8 hours [ DST ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

 Search for: