round physics objects getting stuck on walls

round objects are getting stuck to the sides of walls indefinitely, with no way to ‘unstick’ them. this happens on the shapetumbler demo application as well (try getting the soccer ball in a corner). this pretty much kills the game dynamic of our game, and I can’t find a fix aside from some crafty collision handler. any advice would be much appreciated!

btw, i added a bunch of other lines to see if it was friction or anything, but even removing the horizontal obj platforms, the ball still gets stuck.

[code]
local physics = require “physics”
physics.setScale(60)
physics.start()
physics.setGravity(0, 9.8) – initial gravity points downwards
physics.setDrawMode( “hybrid” )
system.setAccelerometerInterval(99) – set accelerometer to maximum responsiveness

function onTilt( event )
physics.setGravity( (9.8 * event.xGravity ), 9.8)
end

Runtime:addEventListener( “accelerometer”, onTilt )

bodies = {}
borderBodyElement = {friction = 0.3, bounce = 0.3}

table.insert(bodies, display.newRect(0, 0, 320, 20))
table.insert(bodies, display.newRect(0, 460, 320, 20))
table.insert(bodies, display.newRect(0, 20, 20, 460))
table.insert(bodies, display.newRect(300, 20, 20, 460))

local obj = display.newRect(0, 100, 230, 10)
obj:rotate(10)
table.insert(bodies, obj)

obj = display.newRect(90, 200, 230, 10)
table.insert(bodies, obj)

obj = display.newRect(0, 340, 230, 10)
table.insert(bodies, obj)
obj:rotate(-5)

for i=1, #bodies do
physics.addBody(bodies[i], “static”, borderBodyElement)
end

ball = display.newCircle(200, 200, 25);
ball.x = 60
ball.y = 30
ball:setFillColor(120, 50, 50, 255)
physics.addBody(ball, “dynamic”, {friction = 0.4, bounce = 0.3, radius = 23})
[/code] [import]uid: 8791 topic_id: 3157 reply_id: 303157[/import]

i don’t know if this is any use:
(from Box2D documentation but i think isBullet=true is also part of Corona SDK)

IsBullet() method   
   
public function IsBullet():Boolean  
Is this body treated like a bullet for continuous collision detection?  

presumably too many bullets will slow down your app though if the collision detection is continuous [import]uid: 6645 topic_id: 3157 reply_id: 9272[/import]

no, it’s not a bullet, nor does it need to detect continuously… It’s just a normal body which is getting stuck all the time. [import]uid: 8791 topic_id: 3157 reply_id: 9304[/import]

Have you tried making the walls much thicker? I think this worked for me. [import]uid: 3953 topic_id: 3157 reply_id: 9315[/import]

I think I have the same issue as you, I emailed my source to Carlos last week.

// red. [import]uid: 7143 topic_id: 3157 reply_id: 9321[/import]

I have had this problem the sticking also… It is second only to the problem of frame rate changing on touch for android apps. [import]uid: 9562 topic_id: 3157 reply_id: 9332[/import]

box2d solution here:
http://box2d.org/forum/viewtopic.php?f=8&t=2630&p=13522&hilit=sticking+to+walls#p13522

maybe Ansca need to expose more of the b2Settings to Corona API

j [import]uid: 6645 topic_id: 3157 reply_id: 9336[/import]

@jmp909 - looks about right.

Carlos / Corona team - can we get some insight on this? should i file a feature request, or is there a workaround? [import]uid: 8791 topic_id: 3157 reply_id: 9407[/import]

It looks like the ball is going to “sleep”, and sleeping bodies do not respond to gravity/tilt changes.

Try setting ball.isSleepingAllowed = false. This worked for me.

https://developer.anscamobile.com/content/game-edition-physics-bodies#body.isSleepingAllowed

You can also set this flag globally for all objects, although for performance reasons it’s only recommended if you really need to.

https://developer.anscamobile.com/content/game-edition-box2d-physics-engine#physics.start_noSleep_

Tim [import]uid: 8196 topic_id: 3157 reply_id: 9412[/import]

brilliant, this sounds completely viable. thank you tim. [import]uid: 8791 topic_id: 3157 reply_id: 9430[/import]

hmmm… this SOUNDS viable, but unfortunately is not a workable solution for me. any other ideas out there? [import]uid: 136791 topic_id: 3157 reply_id: 131163[/import]

hmmm… this SOUNDS viable, but unfortunately is not a workable solution for me. any other ideas out there? [import]uid: 136791 topic_id: 3157 reply_id: 131163[/import]

Hi all,

Anyone still having this issue or something similar should double check that they are not drawing their walls backwards. I’m not sure if this is the same problem as above, but I had a similar effect happen with my code.

I realised that the Wall rectangle was being drawn backwards. My code for my right wall was

rightWall = display.newRect(\_W, 0, -10, \_H)

The -10 draws the wall as a border 10 units from the right of the screen, which was fine, but on collisions, it caused this sticking effect. The solution was to change the wall code to:

rightWall = display.newRect(\_W-10, 0, 10, \_H)

Just double check that your wall is not being drawn inversely.

Michael Piercy
Pixelw Wolf Studios [import]uid: 156990 topic_id: 3157 reply_id: 131594[/import]

Hi all,

Anyone still having this issue or something similar should double check that they are not drawing their walls backwards. I’m not sure if this is the same problem as above, but I had a similar effect happen with my code.

I realised that the Wall rectangle was being drawn backwards. My code for my right wall was

rightWall = display.newRect(\_W, 0, -10, \_H)

The -10 draws the wall as a border 10 units from the right of the screen, which was fine, but on collisions, it caused this sticking effect. The solution was to change the wall code to:

rightWall = display.newRect(\_W-10, 0, 10, \_H)

Just double check that your wall is not being drawn inversely.

Michael Piercy
Pixelw Wolf Studios [import]uid: 156990 topic_id: 3157 reply_id: 131594[/import]