[BEHAVIOR] Chipmunk Physics

  • Oh ok I'll look into it then. i wasn't aware of a motor strength option. Thanks.

  • R0J0hound

    Not sure if this is a bug or not, but it seems in Chipmunk the 'angular velocity' set is twice as fast as it should be.

    I used speed=distance/time. Constant time, a set target angle, I calculate the angular speed. I used a timer to stop the rotation after the set time.

    In standard C2 physics behavior it reaches the target angle as expected, but in Chipmunk it would over rotate, then I just divided it by 2 and then it worked fine. Both C2 Physics and Chipmunk is stated as degrees per second.

    This does not need any updating of the behavior as we can simply just divide by 2, but I thought I'd put it out there.

    Also Chipmunk crashes if I make an object rotate past its min or max angles set in its limited rotary joint.

  • It’s twice as fast because the timestep is set to 1/30 by default. Setting it to 1/60 will be closer to par. You can also set the stepping from fixed to frame rate independent but it seemed to make things more unstable.

    That’s no good it crashes. Guess that goes along with not setting position and velocity for best results, which includes angles.

    Sounds like something that would need to be fixed in the library itself.

  • Thanks for clarifying. My bad.

  • R0J0hound

    Do you have a discord or any means of privately messaging you? I need your feedback on something. Might as well post it here, doesn't have to do anything with chipmunk

    cdn.discordapp.com/attachments/183566321156358144/502108488869085196/rot.capx

    Was trying to make a voxel type editor but it is not very efficient at all.

  • I have a discord I haven’t used in ages. I probably should install it again.

    Edit:

    My discord name is reddog

    Had a look in your capx. Didn’t have “Rex function” or “polygon” installed so I removed them. Looks like one wasn’t used and the other, polygon was just another option from paster.

    I will say the polygon plugin is probably your biggest bottleneck. It has the same issue the canvas plugin had. It draws to a hidden canvas first and is copied to a webgl texture. This is slow and uses a lot of memory when drawing many polygons.

    I noticed you’re using some JavaScript. I usually define the functions once in a start of layout. To make the functions accessible later you’d define them as

    window.myfunction = function(){};

    Instead of

    var myfunction = function(){};

    Or

    function myfunction(){}

    And the beauty of it is you’d still be able to call the function as myfunction().

    Window is the global object.

    You can do it with just events as well. Might look more readable.

    One thing I do to make my expressions more readable is to avoid using tokenat or even array.at as much. Probably just a personal preference.

    For max performance you could do almost everything in JavaScript and only do minimal stuff in events like add cubes, set the view rotation, and request it to be drawn. Kind of loses the fun of using construct though if you run into js errors.

  • R0J0hound

    Oh thanks for looking into it. I kinda just forked it from things I found from google searching. I have ~0 knowledge of JavaScript (if any) and to be honest C2 is the only thing I am familiar with.

    I indeed was switching between polygon and paster. I just left both in as an option. Polygon has a 'draw line' option which helped distinguish the cubes. Paster is in much lower resolution and as the performance was already slow I didn't attempt to see how it would look if I increased Paster's resolution.

    What I attempted to do was to only calculate the 3D view of one cube at the center, and then to just apply it to the rest of the cubes, maybe helping in performance. But I couldn't figure it out. As it is now it calculates the view for every cube.

    I think it would be great if everything could just be done in javascript for performance but that is way beyond my knowledge.

    I will define the function onStartOfLayout and see how it goes. Thanks

  • Pandy

    I got carried away with some ideas and I posted an example here:

    construct.net/en/forum/construct-2/your-construct-2-creations-23/more-rojo-tests-138761

    Came out pretty clean. The idea is you generate the cube image any way you want, then only once per frame load an animation frame.

  • Are there any way to draw the joints like in the Joints and Constraints video example?

  • You’d have to do it manually. Ideally there are expressions to get the position and such I’d the joints. Or if not you could save the values when you add the joints.

    Then you’d just position sprites or use a drawing plugin to place lines and stuff

  • You’d have to do it manually. Ideally there are expressions to get the position and such I’d the joints. Or if not you could save the values when you add the joints.

    Then you’d just position sprites or use a drawing plugin to place lines and stuff

    I'll try those out... Thanks a lot!

  • Try Construct 3

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

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

    Hi

    is it possible?

    in Chipmunk Construct2?

    1 Ragdoll Player (he can walk on stairs)

    2 Walk Mecha (he can walk on stairs)

    3 Bike

    4 Car

    5 Tank

    Like in This Video.

    youtube.com/watch

  • nelostic

    The behavior lets you utilize joints and collision filtering. Those would be used as the building blocks to make the more complex examples you listed. I have no pointers at the moment but it's just the kind of thing you'd just figure out to do as you go.

  • R0J0hound

    How make No Collision

    of Group (Familly) ?

    Like in Box 2d

    For make ragdoll doll.

  • Hi, one question please, is this behavior more advanced than the official one included in C2? Does this behavior allow us to do more things ?.

    Or can the same things be done with the two behaviors and are they just different?

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