Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
How to cancel collision on pre solve — Gideros Forum

How to cancel collision on pre solve

bysregbysreg Member
edited October 2012 in General questions
just like the title, how can i cancel collision on presolve?

thanks

Comments

  • @bysreg
    what do you mean by canceling collision?
    1) do not call collision callback
    2) do not allow for objects to collide and let them pass through each other?
  • what i mean is like in box2d,

    void PreSolve(b2Contact* contact, const b2Manifold* oldManifold)

    {

    b2WorldManifold worldManifold;

    contact->GetWorldManifold(&worldManifold);

    if (worldManifold.normal.y < -0.5f)

    {

    contact->SetEnabled(false);

    }

    }

    the "contact->SetEnabled(false)" will cancel the collision between that two fixture. so, originally, the two fixtures will collide but i want in some cases they dont collide

    Likes: Yan

    +1 -1 (+1 / -0 )Share on Facebook
  • ar2rsawseenar2rsawseen Maintainer
    edited October 2012 Accepted Answer
    Well contact object is not implemented in Gideros, but I think you could save reference to fixture and then simply set
    fixture:setSensor(true)
    to allow object to pass through and then change it back to false
  • I've managed to turn collisions off and on (in this case an open lid of a box that I wanted a ball to pass by at launch but bounce off later in the game once the lid was closed) using:
    lidBody:setActive(false)
    lidBody:setActive(true)
    No idea if that's legitimate as box2d is mostly suck it and see for me, but it worked for what I wanted to do.
  • @ar2rawseen & petec
    yes, that solve the problem. what i do is set it to sensor when pre-solve, and set it to non-sensor in post-solve
  • willydawillyda Member
    edited February 2013
    local function onPreSolve(event)
    local contact = event.contact
    contact:setEnabled(false)
    end
Sign In or Register to comment.