[BEHAVIOR] Chipmunk Physics

From the Asset Store
Simple yet very life-like rag doll made with Physics!
  • tucamone

    Gravity is global so you could either disable gravity and every tick apply a force to each object so they have their own gravity, or you can leave the gravity on and cancel gravity on so objects by applying a force opposite the direction of gravity on an object's pre step.

  • I need two things that C2 Box2D can't do and Chipmunk sadly neither, at least it seem that way. I just want to make sure.

    1. Setup collision polygon during the gameplay (i.e. by event, programatically).

    2. Apply force from multiple points inside the sprite which need to be setup/adjusted during the gameplay, not before.

    The reason I need this, is the physics wrapping object that would wrap multiple adjacent squares as one. Moving dozens of joint squares might bring a huge performace issues + it doesn't work as intended anyway. If anybody is interested there i complete question:

    If there is a way to achieve this with the Chipmunk I would really like to hear it. I should have tried that before buying the license =( I thought changing things like image points or collision polygons via events is the natural thing to do.

  • mh11


    The collision polygon isn't something the C2 usually lets you do, and the behavior just grabs from that. The only plugin i know of that let's you change the collision polygon is yann's polygon plugin, but I haven't tested it recently to see if it works well with the behavior.


    It's very simple with this behavior. Just apply a force at an offset. The offset can be any point on the object and applying multiple forces work as expected

    For what you're actually trying to achieve the best current solution is to join all the objects together with physics joints, but even then it can't be completely rigid. A proper solution where all the joined objects form one rigid object is possible with the box2d or chipmunk libraries themselves, but nothing is exposed to C2 for design reasons. The question to do it has come up before and my proposed solution then was to use the chipmunk library with js instead of the behavior.

  • Well I think I chose the wrong tool for this particular idea. C2 seemed to have everything I need in simple and quick-learned package. Yet physics is not one of them. I've just realized I can create instances on the fly, but there is apparently no way to refer them from the physics engine. Well, my bad. I should have tried free edition first.

    I don't want to give up on C2 though. GM would take me a lot more time to get familiar with. That's why I ditched the idea of learning Unity in the first place. I have experience in coding in some languages but nothing suitable for games, plus it would take me ages to make something professional looking and fun to play. I like how you can make a lot with just several events, that would normally require tons of lines. As a game designer, graphic designer and programmer in one person, C2 is maybe one and only way to make game(s) in reasonable time and without spending months or years getting familiar with it.

    I'll try to re-think the whole concept without physics, but it will most likely destroy the whole gameplay. I've seen some very complex games made with C2, so I guess if I avoid physics for the time being, there shouldn't be "anything" that I couldn't do with C2. My OT stops here.

  • mh11

    I don't follow. How are you not able to to refer to them from physics? Guess I'll have to look at your other topic.

  • R0J0hound I haven't mentioned that there. I just found out. Maybe I'm wrong, I'm pretty new to C2. Whenever I want to make a joint or apply force with regular physics I can't see how to address specific instance in the event. It always applies to all of them. I couldn't find anything on that topic via google either.

  • mh11

    I've seen the question come up often and there are two solutions.

    One is to pick one object and store it's values in a variables and then in a separate event pick the other one and use the values to do something. One quick thing you can save to a variable is the object's iid then you can use expressions like Sprite(1).x+sprite(2).x to add the x values of two separate instances for example.

    Another more useful thing you can do is to make a family containing only that one object type, then in events you can pick two separate instances independently. If you use C2's physics you have to use the family route.


    With the chipmunk behavior it makes things simpler, you specify the uid of the other object to attach the joint to and avoids having to use a family or even picking at all if you want to design joints in the editor.

    https://dl.dropboxusercontent.com/u/542 ... test2.capx

  • I've heard this has better results than box2d... might someone be able to tell me how to apply force at angle?

    I can see there's apply at offset, etc... but I'm trying to covert my current code over. Isn't it as simple as apply force at 90 degrees? I keep reading that this is used for joints etc... so am I using it for the wrong thing?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • AnD4D

    I'm using chipmunk for racing game, and I have made the turning by applying force at offset:


    Up arrow controls the force

    Left and Right controls the offset

  • neverk

    Surely that means you have to have a bunch of variables controlling such things. The simplicity of the normal physics engine is you just set the physics force strength and the angle.

    My code currently simulates something of a black hole. The closer you are to it, the greater the force. Can't see how I'd achieve the same with this one.

  • AnD4D

    That could be achieved by setting force (polar) to

    force : max amount - clamp(distance(object.x,object.y,blackhole.x,blackhole.y),0,max amount)

    angle : angle(object.x,object.y,blackhole.x,blackhole.y)

  • I use chipmunk for the joint capabilities, here is something I was working on last year:

  • Please someone help me, I have a falling box with physics behavior i want to change his direction when i swipe, the box will move to right or to left and continue to fall as the image below

    Im using chipmunk plugin

  • Hello MarkeGamer,

    I've never used the touch but, basicaly I think just check the direction of the touch (with somethin like touch start and touch end, I don't know) and apply an impulse with Chipmunk physics at that direction or an angle (switch to polar when setting the impulse).

  • MarkeGamer you could do it like

    is in touch Box Set angle towards (touch.x)


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