[BEHAVIOR] Chipmunk Physics

From the Asset Store
Simple yet very life-like rag doll made with Physics!
  • Any way to change friction/elasticity per collision? I'm trying to get a collision response to make an object bounce without friction, and then set it back so that other objects keep their friction/elasticity when they collide.

    I also tried calculating my own response by reflecting across normal, etc, but it doesn't work.

    edit: I got the reflecting working, but the friction still gets applied. I can't find a way to turn off the friction during a collision.

  • alright, this seems to work:

  • edit: figured it out- tilemap was set to box instead of poly.. not the polygons are working per tile.

  • Apparently you can't collide two segment shapes together??

    is this a bug R0J0hound ?

    edit: I checked the chipmunk docs, and apparently segment shapes can't collide with other segment shapes.. I guess I'll have to try and find some alternative.. maybe a thin polygon- I'll try that.

    edit: I tried a thin polygon, but I get an error stating that the moment of inertia must be positive and non-zero. line 52 (col 3).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Newer versions of the chipmunk library can have segments collide with segments, but it wasn't ported to JavaScript when I made the plugin.

    I'm guessing you got that error because the inertia was set to zero. Maybe because of zero area. Just make it a hair thicker.

  • R0J0's been quite lately because being hound he was looking for me Lord Shiva

  • R0J0hound , I found a bug that causes the game to freeze <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad">

    capx: https://1drv.ms/u/s!AhHSZHEulqh_gWHiXC4TP0AV8S7_

    Seems to happen when you use a 'on pre collide' for an object, and set its velocity at the moment when a group of object collide at the same time.

    If you run the capx, it will freeze after a moment when a few boxes collide at exact same time, I think.

  • R0J0hound , actually.. it appears it happens when an object is asleep. I positioned one to sit above the tilemap and forced it to sleep state on start of layout, and then on pre collide it immediate freezes when velocity is set.

    edit: I'm guessing the pre collide isn't meant for applying velocity/etc.

  • Prominent

    That's odd, but I don't think i'll be able to fix it. It appears to be a bug with the library itself.

    When those triggers are called the simulation is in a locked state where only certain things are allowed to happen. To make it work the library delays certain things from being done until the simulation is no longer in a locked state. Also on top of that i've added stuff on top of that. The result is too many cases where things can fail.

    The bug here is with waking up sleeping objects when the library is in a locked state.

    I guess the workaround for this particular case is to either disable sleeping, or keep those objects awake with a "every tick: wake sprite" event.

  • R0J0hound , thanks for the info. Are there any cases that you know of besides 'on pre collide' where this may happen? I just experienced the freeze without any 'on pre collide' actions. Maybe it tried waking up in the 'on pre collide' even though no actions were ran inside the event?

    I'm going to disable sleeping for now- I don't plan on having too many objects at a single time.

  • I'm not aware of any others besides the collision pairs loop i think.

  • Wow the work put into this, stunning! Thanks for all your hard work!

  • Whats a good way to handle a simple knockback... e.g. object 1 hits object 2, knockback object 2 at the angle it was hit.

    I've been testing a few things with the various chipmunk actions and nothing seems to work

  • Badmiracle

    Usually if both objects have the behavior, the knock back is automatic. Or if you want it to be more severe you could apply an impulse on post collide. If one object doesn't have the behavior you can still apply an impulse.

  • R0J0hound , I'm trying to get the object being collided with inside a 'for each collision pair' loop.

    It seems to work when objects collide, but then afterwards it just returns 0 for the Chipmunk.CollisionOtherObj value.

    This is strange, because the loop runs when objects are touching each other after colliding, but the Chipmunk.CollisionOtherObj returns value of 0.

    I need this, because the recent colliding object may not be the value I want if the object colliding is resting on another object and stops touching the recent collided object. I want it to return the original colliding object it still is touching, but it won't until it re-collides.

    edit: I might be able to use an alternative method by checking if things overlap..

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