How do I disable physics collision, if already colliding?

0 favourites
  • 4 posts
From the Asset Store
Particles support animations, collisions, effects and etc.
  • I'll try to keep this short and simple, i tried to search, but didn't find anything, but maybe this is something really simple:

    so, two physics objects, on top of each other. the bottom one immovable, the other one resting on top of the bottom one. i click a mouse button and i want to disable physics collision between the two objects so that the top object falls through the bottom one, but nothing happens. they keep colliding. i tested stuff and i came to the conclusion that the -disable physics collision- action does not work if the objects are already colliding.

    is it me not getting something obvious, or is it just the nature of the beast? and more importantly, is there any (simple-ish) way around this?

  • I think after the collision the top object is in 'sleep mode' and disable the collision isn't changing this state.

    Try:

    + Mouse: On Left button Clicked on TopObject
    -> TopObject: Disable Physics collisions with BottomObject
    -> TopObject: Set Physics Immovable
    -> TopObject: Set Physics Movable
    

    Or you could disable and enable the physic-behavior of the top object. That should reset the state.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for replying!

    this works, BUT it won't work in a situation where the top object is moving, for example sliding on top of the bottom object, because in this case it will stop. i could perhaps store the velocity X + Y in variables to circumvent this, but i would like to have a bit more unintrusive way to do this. basically letting the top object just mind it's own business, intact, whatever it is doing on top of the bottom object.

    is there any other way to refresh the collision?

    (i did find another way around this: make a second animation frame for top object, shrink the collision box just a tiny bit, then set the frame after (or before) disabling collision. it works but again, it is kinda hacky method, and i would still like the top object be intact, in its original form)

  • I think that is all more or less hacky. If it works with the animation it's a good idea.

    The other idea I had is you could store the whole instance asJSON in a variable.

    + Top: On collision with Bottom
    -> Top: Disable Physics collisions with Bottom
    -> Top: Set temp to Top.AsJSON
    -> Top: Set Physics Immovable
    -> Top: Set Physics Movable
    -> Top: Set from JSON string Top.temp
    

    But I think that is more hacky than your solution.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)