[BEHAVIOR] Chipmunk Physics

3 favourites
From the Asset Store
Simple yet very life-like rag doll made with Physics!
  • What is it?

    A new physics behavior that uses Chipmunk Physics instead of Box2d. It's built on a JavaScript port found here: https://github.com/josephg/Chipmunk-js which is based on Chipmunk2d 6.1.1.

    It differs from C2's physics behavior in a few ways. For instance this behavior works when you manually set positions at runtime and you don't have to wait a tick before adding joints. Also the Warp behavior will work with this one without a hitch. Another difference is when adding joints you use an object uid instead of picking the other object, which simplifies adding joints between instances of the same type.

    Features:

    * Collision shapes: None, Box, Circle, Polygon and rounded Segments. (Segments can't collide with other segments)

    * Support for concave polygons.

    * Support for tilemap object.

    * Standard object properties: Mass, Elasticity and Friction which can all be set at runtime.

    * Collision filtering:

    1. Collision groups that allow objects not to collide with other objects in the same non-zero group.

    2. Collision layers which is basically 32 different layers, and the object can be in any number of them, and will only collide with objects that share a layer.

    * Additional expressions: inertia, center of mass and area.

    * Every joint chipmunk2d has to offer is available to use. http://chipmunk-physics.net/release/ChipmunkLatest-Docs/#cpConstraint-Video

    * Ability to specify where on the object's the joints are attached.

    * Ability to destroy individual joints, get the current impulse applied to a joint, and get the number of joints an instance has.

    * Global properties: Damping, Iterations, fixed timestep, and Gravity.

    * Ability to set and get: Velocity, angular velocity, force, impulse and torque.

    * All actions that set force, impulse, velocity, gravity, etc,... can be set with an xy or an angle and magnitude.

    * Force and impulse can be applied to an offset on the object.

    * Collision info with the "Post Collision" condition. With it you can get:

    1. Kinetic energy of collision.

    2. Impact of a collision.

    3. UID of other chipmunk object hit

    4. Number of contact points and the point, normal and penetration depth of each.

    * Closest point and Segment ray casting with expressions to get the point, distance, and normal with ray-cast.

    * Utility expressions to convert coordinates from layout (world) to local (relative to the body) and back.

    * Ability to set speed limits to objects and force limits to joints.

    * Chipmunks automatic object sleeping with actions to manually put to sleep and wake up.

    • As well as global properties to set the "idle speed threshold" and the "sleep time", which is the time idle before going to sleep.

    Download:

    https://app.box.com/s/jt9f8r1mqmq07pbthiydvrgzikp5d29f

    To install extract zip file into "C:\Program Files\Construct 2\exporters\html5\behaviors".

    Simple joints Example:

    https://www.dropbox.com/s/glddumkw3mt64 ... .capx?dl=0

    Conditions:

    Actions:

    Expressions:

    -cheers

  • It seems faster than Box2D to set positions, nice

  • Hmm, R0J0's been quite lately.

    He must either be:

    A. Teaching Chuck Norris how to be a computer ninja, or

    B. Making a paradigm changing plug.

  • Looks great , hopefully it will work out , will keep an eye on this .

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I will definetely watch out for this

    But as soon as this behavior is completed, we definetely need an Performance Comparison.

    Keep up the good work R0J0

    I definetely see possibilities when we think about Moddability,

    with setting an Collision Polygon at runtime.

    Looking forward to see this complete and compete.

    • Conti
  • Uploaded beta #2.

    + Got circle and polygon collisions working. However concave polys are currently just converted into convex hulls.

    + It works now if the origin is off center.

    + Added joint I forgot (rotary limit joint).

    There were a couple issues that came up that took longer to work around than expected. As a side effect body sleeping may not be possible now, but we'll see.

    newt

    Don't need to teach a guy that can roundhouse kick his keyboard and get millions of lines of error free code.

    granpa

    Thanks.

    Joannesalfa

    SgtConti

    I'm not really going for speed, but function. But it could be interesting to benchmark when it's done*.

    SgtConi, changing the collision shape at runtime is more along the lines of changing the collision type. ex. None,Box,Circle or Poly. Changing the points of the collision polygon is another deal, which could prove tricky since chipmunk2d only works with convex polygons.

  • R0J0hound

    I assume there will be an option to change Mass at runtime ?

  • waiting on it

  • R0J0hound

    I assume there will be an option to change Mass at runtime ?

    yep

  • Played around with it a bit, it feels better/funnier than original box2d. Looking forward to it.

  • I just wanted to test it, added Chipmunk to two different objects and voila:

    Anyway, i hope you continue working on this one R0J0, seems pretty promising

    • Conti
  • SgtConti

    Can you provide more details or a capx where it occurs? I don't get an error when using two sprites. Although tiledBg does seem to have an issue when the hotspot is top-left.

    I've been on a break from coding for a bit, but I should be resuming soon.

  • I tried to find out the issue and tried to reconstruct it in a capx, but i can't :/

    I will try to continue find out when it occurs and notify you when i do

    Also, is there going to be rotation?

    • Conti
  • [quote:3s96hura]Also, is there going to be rotation?

    It already has rotation. Objects rotate on collision and there are actions to set angular velocity and torque. Unless you mean something else?

  • When i used it they does not seem to rotate on collision :/

    Is there an option i missed?

    Anyway, i found the bug.

    It occurs when using Node-Webkit. But it does not occure when using Chrome.

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