Expose Box2D velocityThreshold parameter to help with sticking objects

I fully agree, I’ve been waiting months with a fully finished game that can’t be released due to this bug. I thought having access to daily builds might help but no luck.
Can someone please let me know if this is actually being looked into? Don’t get me wrong I love corona and have one game already published using it, however unless this gets sorted I’m going to have to start looking at other framework options.

Thanks. [import]uid: 13522 topic_id: 3536 reply_id: 49180[/import]

@infuseddreams: I totally agree with you!!! [import]uid: 9058 topic_id: 3536 reply_id: 49302[/import]

MY PROBLEM IS SOLVED (it isn’t the problem described above, though) – see all the way to the bottom. Yes, my problem was something else, but just in case someone else encounter similar problem, I thought I’d share this. So… here it is:

My game is also born out of Simple Pool that came with the SampleCode. And YIKES, I got the sticky wall – just came up last night, and I could not find the way to fix it. I can’t even see why it’s not working. It makes zero sense to me.

The thing is, I’m not sure if changing the velocityThreshold parameter would make any difference – at least not with the problem I’m having.

I have four walls surrounding a rectangle “table”. I’m calling these walls bumpers (just like it does in Simple Pool project.) The top & bottom bumpers work just as expected while the right & left bumpers don’t. When I hit the “cueball” super hard (or very soft, or whatever – velocity doesn’t have anything to do with this) against the right/left wall, it gets stuck, while it bounces back perfectly fine from top/bottom bumpers. I can’t unstick the “cueball” once it’s glued on to a bumper.

Here are bumper settings for all four bumpers I’m having problem with. Notice how bumperBody settings are identical, except for the shapes of the bumpers. (Note: All local variables are being forward referenced at the top of my lua module).

 bumperShapeWall1 = {-220,-20, 220,-20, 220,0, -220,0}  
 bumperShapeWall2 = {0,-220, 0,220, 20,220, 20,-220}  
 bumperShapeTriangle1 = {-98,0, 98,0, 0,30} -- triangle top/bottom  
 bumperShapeTriangle2 = {20,-135, 20,135, 50,0} -- triangle right/left  
 bumperBody1 = {friction=0.5, bounce=0.5, shape=bumperShapeWall1}  
 bumperBody2 = {friction=0.5, bounce=0.5, shape=bumperShapeWall2}  
 bumperBody3 = {friction=0.5, bounce=0.5, shape=bumperShapeTriangle1}  
 bumperBody4 = {friction=0.5, bounce=0.5, shape=bumperShapeTriangle2}  
 -- top bumper  
 imgWidth = 320;  
 imgHeight = 60;  
 posX = 0.5 \* (screenW - imgWidth);  
 posY = 25;  
 local boardBumper1 = display.newRect(posX, posY, imgWidth, imgHeight);  
 boardBumper1.alpha = 0;  
 physics.addBody(boardBumper1, "static", bumperBody1, bumperBody3);  
  
 -- bottom bumper  
 posY = 395;  
 local boardBumper2 = display.newRect(posX, posY, imgWidth, imgHeight);  
 boardBumper2.alpha = 0;  
 boardBumper2.rotation = 180;  
 physics.addBody(boardBumper2, "static", bumperBody1, bumperBody3);  
  
 -- left side bumpber  
 imgWidth = 60;  
 imgHeight = 380;  
 posX = -45;  
 posY = 49;  
 local boardBumper3 = display.newRect(posX, posY, imgWidth, imgHeight);  
 boardBumper3.alpha = 0;  
 physics.addBody(boardBumper3, "static", bumperBody2, bumperBody4);  
  
 -- right side bumper  
 posX = 305;  
 local boardBumper4 = display.newRect(posX, posY, imgWidth, imgHeight);  
 boardBumper4.alpha = 0;  
 boardBumper4.rotation = 180;  
 physics.addBody(boardBumper4, "static", bumperBody2, bumperBody4);  
  

By the way, I tried using PNG image of the bumpers (i.e., instead of using display.newRect, I used display.newImage for the bumpers with exact shape), but it didn’t make any difference.

EDIT:

Based on Danny’s comment, I re-did the bumpers, and it worked! Thanks Danny!

http://developer.anscamobile.com/forum/2011/02/11/sticky-walls#comment-51781

So, just in case someone else is having a similar trouble, here’s the bumper shapes that worked. Compere the ones from the above to this one, and you’ll see what needed to be done.

 local bumperShapeWall = {-220,-20, 220,-20, 220,0, -220,0}  
 local bumperShapeTriangle1 = {-98,0, 98,0, 0,30} -- triangle top  
 local bumperShapeTriangle2 = {-135,0, 135,0, 0,30} -- triangle right/left  
 local bumperBody1 = {friction=0.5, bounce=0.5, shape=bumperShapeWall}  
 local bumperBody2 = {friction=0.5, bounce=0.5, shape=bumperShapeTriangle1}  
 local bumperBody3 = {friction=0.5, bounce=0.5, shape=bumperShapeTriangle2}  

[import]uid: 67217 topic_id: 3536 reply_id: 51776[/import]

i am new corona i am developeing one ball game in that game i have one problem please help me that problem is i create staic diamond shape object in that center i want to please the ball in the center diamond in that please i have problem the ball is collied to the diamond shape the ball bodytype is dynamic please help me to slove the problem [import]uid: 91542 topic_id: 3536 reply_id: 67887[/import]

The only way I could begin to get around sticky walls is to avoid creating my objects near the walls. [import]uid: 106991 topic_id: 3536 reply_id: 69701[/import]

Had to break through some high-security fence lines, incapacitate several guards (Chuck/Intersect-style), disable several security tapes, and route this message through 10 different servers, but here it is!

The *unofficial* API’s to get you what you need. If you ask us any questions after this, we will disavow any knowledge of this post. (This forum post will self-destruct in 15 seconds…)

To set velocity threshold and other Box2D contants, you can use the following. MKS stands for the standard unit system meter-kilogram-seconds:

physics.setMKS( key, value)
physics.getMKS( key )

The argument ‘key’ can be:

“velocityThreshold” (corresponds to b2_velocityThreshold)
“timeToSleep” (corresponds to b2_timeToSleep)
“linearSleepTolerance” (corresponds to b2_linearSleepTolerance)
“angularSleepTolerance” (corresponds to b2_angularSleepTolerance)

These will be available in build 700 (or after, if 700 fails to post)

Again, we will disavow any knowledge of these API’s, so use at your own risk. And you did not hear it from me [import]uid: 26 topic_id: 3536 reply_id: 70917[/import]

Great Success!

Thanks Walter I mean Anonymous poster.
[import]uid: 7177 topic_id: 3536 reply_id: 70940[/import]

Wow, that is some great news! Hmm…forgot what about…
:slight_smile:

Alex [import]uid: 4572 topic_id: 3536 reply_id: 71018[/import]

Fantastic ! [import]uid: 55808 topic_id: 3536 reply_id: 72378[/import]

awesome! Well, I know what I’ll be doing this weekend… [import]uid: 49447 topic_id: 3536 reply_id: 72693[/import]

Hi.

I’m facing the same issue with sticky moving objects in pool-like game (gravity(0,0)).

I have a kinematic body, that is moving in a loop from left to right. It’s done in enterFrame, by using: object:translate() (changing this to setLinearVelocity() gives the same result)
[lua]local kinematicBody= display.newRect(staticObstGroup, 0, 0, 10,7)
kinematicBody:setReferencePoint(display.CenterReferencePont)
physics.addBody( kinematicBody, “kinematic”, {damping = 0, isBullet = true, friction = 0, bounce = 1} )
[/lua]

and a ship, that moves through the screen.

[lua]local ship = display.newImageRect(“images/ship.png”,22,22)
ship:setReferencePoint(display.CenterReferencePont)
ship.x =_W/x; ship.y = _H - y;
ship.myId = “Ship”
ship.isReady = false
physics.addBody( ship, “dynamic”, {isBullet = true, damping=0, friction = 0, bounce = 1, radius = 11} )[/lua]

at certain circumstances (angle) when ship approaches the moving kinematicBody, it can stick to the thinner wall (left/right), and very slowly slide down it, releasing the sticky slide after going to the bottom (or top) of the sliden wall.

i used every possible solution found on the web, including setting:
physics.setMKS(“velocityThreshold”, 0.01)
physics.setMKS(“timeToSleep”, 0.1)
physics.setMKS(“linearSleepTolerance”, 0)
physics.setMKS(“angularSleepTolerance”, 0)
trying rounded rects instead of regular ones (sticky slide still occures on the curved border), and even turning off the movement of the kinematicBody on event.phase == “began”, and bringing it back on event.phase == “ended” while it was colliding with the ship object.

unfortunatelly, it still didn’t solve the issue.

maybe You brilliant people have any ideas?:slight_smile:

take care!
mike

update:

it looks like while occurance of the sticky-issue, there is instant collision after the first one:

began 172.07287597656 245.7456817627
ended 160.3849029541 -253.52851867676
began 160.3849029541 -253.52851867676
ended -297.43087768555 -39.177352905273
[import]uid: 77763 topic_id: 3536 reply_id: 79047[/import]

Just to let You know, seems like the workaround solution was setting the physics.setScale() to an enormous amount. 240 did the job in my case. [import]uid: 77763 topic_id: 3536 reply_id: 79055[/import]

Did anyone find a solid solution to this very frustrating issue?

Thank you for your response [import]uid: 122802 topic_id: 3536 reply_id: 96592[/import]