Box2D Forums

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

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Fri Feb 10, 2012 6:31 am 
Offline

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
 Profile  
 
PostPosted: Fri Feb 24, 2012 4:51 pm 
Offline
Site Admin

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
 Profile  
 
PostPosted: Fri Feb 24, 2012 6:20 pm 
Offline

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
 Profile  
 
PostPosted: Tue Feb 28, 2012 2:24 pm 
Offline
Site Admin

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
 Profile  
 
PostPosted: Tue Feb 28, 2012 9:47 pm 
Offline

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
 Profile  
 
PostPosted: Tue Mar 06, 2012 11:55 am 
Offline

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
 Profile  
 
PostPosted: Tue Mar 06, 2012 11:57 am 
Offline

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.


Attachments:
OneSidedPlatform.h [3.91 KiB]
Downloaded 64 times
Top
 Profile  
 
PostPosted: Sun Mar 18, 2012 12:22 am 
Offline
Site Admin

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
 Profile  
 
PostPosted: Sun Mar 18, 2012 3:50 am 
Offline

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
 Profile  
 
PostPosted: Sun Mar 18, 2012 10:49 am 
Offline
Site Admin

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
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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 forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group