[BEHAVIOR] Chipmunk Physics

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

    You'll have to approximate it with a polygon. Both chipmunk and box2d only do circles and polygons.

  • I supposed that, but thank for the reply!

  • I am a bit puzzled here.

    I always thought that changing the gravity of one object does not change the gravity of the other objects.

    Apparently, it does, change the gravity in one object and you do for all objects.

    As shown in this capx:

    https://drive.google.com/open?id=0B1SSu ... 25zZkRiQWs

    But i dont really like that idea. I like things to be consequent. Pick an object and the actions run on that object only. After all gravity is no more then a force as all forces.

    So i wend to chipmunk.

    https://drive.google.com/open?id=0B1SSu ... jlON3VQMkU

    To my suprise, it does the same.

    So i have two question, if that is ok.

    1/ Why is it logic that there is only 1 gravity? There is probaly i good reason that i cant find.

    2/ Why does the red object in chipmunk waits with falling until it is touched by another physics enabled object ?

  • 99Instances2Go

    1)

    Gravity is an acceleration and is the same for everything so it makes sense to affect everything.

    2)

    I can't look at the capx but it probably has to do with sleeping. Sleeping is an optimization where if an object stops it can be put in an idle state so calculations don't have to be done on them. It then wakes up if anything moving touches it or you move it. You can adjust how likely objects will fall asleep.

  • ty

  • Guys, hello! What do you think because of the chipmunk may have problems with canvas +? When I pick up on vebviev + everything works fine, but with canvas + Black Screen saver field cocoon. Configure the project as it is necessary, with a black screen topic has already been uvas! But there about chiptyunk neither of which is not written!

    Ребята, привет! как вы думаете из-за chipmunk могуть быть проблемы с канвас+ ? Когда я собираю на вебвиев+ все работает отлично, но с канвас+ черный экран поле заставки кокон. Настроил проект так как нужно, тема с черным экраном уже была увас! Но там про чиптюнк ни чего не написано!

  • Might there be any chance of us getting angular dampening included in the near future? I know we can manually do it by having an opposing angular force, but it's just nice having it as a feature in box2d.

  • RashidBASHLY

    There shouldn't be an issue with canvas+ since this plugin makes no use of drawing. Only js is used. Also I only use html5 and nwjs exports.

    AnD4D

    I probably won't be getting around to this any time soon as I don't have a lot of time lately.

  • R0J0hound Ah, I see... Well what you've done is greatly appreciated

    I have noted what might be a bug if you're interested. I tried to change an objects mass using runtime, and an error message popped up. Perhaps this isn't a bug, but it seemed strange. I'll need to figure out another way to achieve this effect.

  • I know, you probably don't have much time to fix stuff with this plugin R0J0hound , but thought I would mention that if I have chipmunk objects on two separate layers, and one layer has a different angle set, objects only use the angle of the layer they are currently on.

    So when colliding, the layer angle isn't taken into account if the object they're colliding with is on a different layer.

    Hope that makes sense.

    I test this with tilemap on a rotated layer, and an object on another non-rotated layer. Object acts as if tilemap isn't rotated. If the object is put on same layer as tilemap, then it acts as if it is rotated.

    Maybe it is a C2 issue?

    edit:

  • I'm curious to know what are some of the best ways/tips to try optimize a project using this behavior? I'm working on a game for a limited hardware and although the performance is better than with C2 standard physics I could still use some helpful advice to improve the framerate further. Obviously I'm trying to keep the object count low and in check, I've also experimented with idle/sleep time threshold values but other than that what steps could I take to optimize further?

    Also, I'm trying to add some bouncing objects into the project but was wondering what's the correct way to do this? Let's say I have a basketball that's supposed to bounce off ground surfaces. I can achieve this by increasing the elasticity value on both the basketball and ground surfaces, but if I want to have the ball also bounce off other objects and increase their elasticity too, these objects will also bounce off the ground surfaces similar to the ball. If I keep the ground surface elasticity low (say 0.2) and instead just increase the ball elasticity to something like 5, they will bounce off the ground as intended, but on collision with other basketballs they are sent flying like a missile:) Any help on what's the recommended way to set this kind of scenario up would be appreciated!

  • Try Construct 3

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

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

    If it crashes it's a bug, and I think that one is known. I haven't worked on it in a while but the plan was to rework the entire plugin so that's easier to fix. The crash is do to some logic error on my part, but it usually occurs when setting the mass under one of the plugin's trigger or loop events. The reason is under those events the chipmunk library itself won't let you change the mass, collision shape,... etc of an object. To alleviate that the change is just delayed till it's allowed to. In short it introduced too many special cases which made it increasingly hard to debug and fix, so an internal rewrite is needed in order to simplify things. I unfortunately don't have the time or interest to work on plugins to that extent, but at least for the most part this plugin is in a working state.

    Prominent

    Yeah, I never investigated handing layers with different parallax, rotations and such. I just left it as unimplemented. Tilemaps can't rotate as I recall, otherwise I would have let them if I could. That bug seems odd, looks like the tilemap's bounding box is being used.

    Waltuo

    Usually you'd keep the elasticity in the range of 0 to 1. I'd make the ground and the first ball 1, and the second ball 0.2 or something. When two objects collide their elasticities are multiplied together.

  • Is there a way to limit On Post collide triggers to run once? Sometimes they run more than once due to multiple collisions at the same time(as far as I can tell). I only need to do certain things based on the last collision, so when it run more than once, it makes errors.

    edit: okay.. seems I figured out the issue:

    I had a condition Sprite.Chipmunk.jointType("Tag")="" in the on post collide. And I was adding the joint in the event, however, it seems it doesn't add it immediately or something.

    I changed it to rely on an instance variable instead, and that fixed the issue.

  • A quick way would be to use a variable like this:

    global variable once=0
    
    on collision
    once=0
    --- set once to 1
    --- do stuff
    
    every tick
    --- set once to 0[/code:239878ee]
    
    That way you'd only get one event per tick on that object type.  Actually you'd want an instance variable instead to have one collision per instance per tick.  Or if you wanted only one trigger per pair of instances you could use a dictionary to keep track of it like:
    
    [code:239878ee]on collision
    X dictionary: key exists min(sprite.uid, sprite.chipmunk.otherUID)&":"&max(sprite.uid, sprite.chipmunk.otherUID)
    --- dictionary: add key min(sprite.uid, sprite.chipmunk.otherUID)&":"&max(sprite.uid, sprite.chipmunk.otherUID)
    --- do stuff
    
    every tick
    --- dictionary: clear[/code:239878ee]
    
    I do not know if the chipmunk library has anything to help with that.
  • Thanks, that dictionary method looks useful- i'll have to remember that if I need to check pairs.

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