[BEHAVIOR] Chipmunk Physics

From the Asset Store
Simple yet very life-like rag doll made with Physics!
  • This plugin is quite amazing and so far it has delivered a far better experience for my game than Box2D has done.

    1 thing that I think could be implemented though is:

    Condition: Compary Velocity

    Condition: Compare Velocity X

    Condition: Compare Velocity Y

  • SgtConti what do you mean by those conditions?

    If I understood correctly, I think what you're asking for is already in there. You can put that kind of a condition through System: Compare two values.. and then typing YOURSPRITE.Chipmunk.VelocityX / VelocityY.

  • I know, but if you have multiple instances, and you need to pick one specific having that specific velocity, that could be a problem.

    At least I dont know how to do it.

    //Edit: I found the system condition to compare the values while picking an instance. The manual is alway helpful, even after 500+ hours of Construct 2 use

  • Try Construct 3

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

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

  • Found a bug (edit: okay nevermind it isn't a bug):

    http://www.filedropper.com/hittinglinebug

    The sprites falling should all turn green, but only one does (because it overlaps the corner??).

    I want to query first hitting line for all the falling objects to know when another object is beneath them. Seems as if this doesn't work as expected.

    edit: on further analysis, it appears that it only triggers when the line is entering the object. It doesn't trigger if the line begins within the object.

    Is there a way to check if a point resides within an object? , then I could use that along with the line check.

    edit2: okay I found a way to solve it. I used two more short lines pointing down at the corners.

  • Is there a way to find the nearest corner of an object? I know there is the nearest point on object event, but that can return points that are between corners. I need a way to get the position of nearest corner/vertex.

  • Prominent

    The best way I can think of would be to create an object at each corner and use the "pick nearest" condition. You'll probably need to define the corners with imagepoints to do that.

  • R0J0hound , ah yea I suppose I could do it that way. I was hoping for something simpler since the objects already have verts to create the shapes. There's no way to access that without editing the plugin or writing my own. I was looking through the runtime and it was a bit confusing, and don't feel like messing with it..

    The sprite already has ability to get x,y of the imagepoints, so I could create imagepoints at every corner and cycle through them checking the distances to find the nearest one, but it gets difficult to manage if objects have different numbers of imagepoints and imagepoints that shouldn't be checked- just thought I'd ask in-case there was something I was overlooking.

    Maybe I'll look at the runtime again and see if I can make sense of it.

  • Or maybe I'll try making my own behavior that checks the polygon in sprites..

    Do you know where that data is kept?

  • Prominent

    I forget exactly where. Search for "poly" in the runtime.js for how I accessed it. It was basically mirroring what the built in physics behavior does. They both use some helper functions that are defined in commonjs.js. (I think that's the file, it's in the exporters/html5 folder).

    The functions allow you to get a list of the points that make up the collision polygon, but transformed to match layout coordinants. The sprite behavior may be another place to find the list of points.

  • R0J0hound , I managed to create a behavior to get nearest polygon point coordinates. The problem I have now is that it isn't correct position if it is retrieved during on post collision in the chipmunk behavior. If I have an object rotating and moving the coordinate is off (maybe it is from the previous game cycle?)..

    Any suggestions on how to apply the correct offsets to get the correct position when a collision happens?

  • Prominent

    Yeah, it looks like it's from the previous position. You can try adding these two lines to line#6528 :

    binstA.updateC2(binstA.body);

    binstB.updateC2(binstB.body);

    That should update the c2 object from it's physics body. I haven't tested it, so I don't know if it has any other side effects, because usually it's only done at the end of the tick. Looking at the function it may but I don't have the time to really analyze and debug it.

  • R0J0hound , Thanks! that seems to help. The positions are more synced now, so now my events are working more like how I expect them to. I'll let you know if I run into any side-effects.

  • Oh my god,

    This plugin is absolutely godly.

    I had been using the default box2d plugin in my project and thought it would be not worth the hassle replacing it with this Chipmunk plugin.

    Well, I done it anyway. And...DAYMN. I need to get measurements, it has improved the FPS dramatically. Not to mention the collision system is much more suited for my project.

    Thank you so much R0J0hound

  • Nice work Hound

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