Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Disable Bouncing of Box. — Gideros Forum

Disable Bouncing of Box.

edited February 2013 in General questions
My simple box has restitution parameter set to 0. But still when it falls from high it bounces from ground and other boxes (ground is a static obj with restitution = 0)

The same problem was posted here but I don't know how to modify b2MixRestitution with Gideros:

http://www.box2d.org/forum/viewtopic.php?f=4&t=5662

Please help me, thank you :D

Comments

  • ar2rsawseenar2rsawseen Maintainer
    edited February 2013
    From my understanding what b2MixRestitution does is decides which restitution to use, and by default it takes max restitution from both colliding objects (or mixes them somehow). If your box has restitution 0 and ground has restitution 0, setting b2MixRestitution won't change anything. Then the problem lies somewhere else.

    Increasing density of object or maybe even friction might help.

    And of course if all fails, you can try some drastical solutions, like creating a magnet from floor :D

    Likes: thanhquan1512

    +1 -1 (+1 / -0 )Share on Facebook
  • edited February 2013
    @ar2rsawseen: Thank you so much.

    As in box2D's documentation: "set restitution = 0 does not guarantee that there is no bouncing". Actually I don't know where is the problem :)

    Edit: Got it, after many tries I decide to slow down box & avoid bouncing, use:
    boxBody:setLinearDamping(number)
  • ar2rsawseenar2rsawseen Maintainer
    Accepted Answer
    @thanhquan1512 I've actually found out the way of overwriting the restitution.

    Set up the pre_solve event and inside it, retrieve contact object and modify it's restitution like this:
    function scene:onPreSolve(e)
        local contact = e.contact
        contact:setRestitution(0)
    end
    Don't know if it will solve your problem, but maybe it'll be useful ;)

    Likes: atilim

    +1 -1 (+1 / -0 )Share on Facebook
  • atilimatilim Maintainer
    I think @ar2rsawseen's solution is great. But when both box and ground have restitution = 0, it shouldn't bounce at all.

    Likes: Diego_85

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.