[BEHAVIOR] Chipmunk Physics

  • Giganten

    It's generally better to use forces and torques to change the motion of the objects. Changing the velocities directly won't give very realistic results although you can increase the iterations setting to make it do a better job of keeping up.

  • Thank you R0J0hound, learned something new today.

  • incase anyone is wondrering, you cant get good collision using this with default 8 dir movement plugin...

  • gogobotz

    When physics is concerned (this or the official physics behavior) it doesn't mix well with other movement behaviors. So to to have 8 direction with physics you'd need to do it all with physics.

  • gogobotz

    When physics is concerned (this or the official physics behavior) it doesn't mix well with other movement behaviors. So to to have 8 direction with physics you'd need to do it all with physics.

    thanks alot with this info i was able to achieve perfect collisions but now i have a question that has been bugging me

    i am trying to keep objects at specific angles when they approach within angles. (like limits) and am unsure the best way? should i apply torque with + or - a number or use built in C2 set angle? I want them to rotate towards a position on a pivot when approaching a certain angle.

  • I noticed there is the option to disable the chipmunk behavior on an object.

    I tried doing this to an object that has a joint with another object, and noticed that the other object still is affected by the joint attached to the disabled object.

    Is there a way to disable/enable the joint as well so I don't have to recreate them everytime I want to disable/enable the behavior?

    R0J0hound , maybe an action to disable/enable a joint given its' tagname?

  • Another useful application of disabling/enabling joints would be if you want to switch between joint types to control the movements of objects that are grouped together in specific ways. I think this could open some unique game mechanics that might be otherwise difficult to manage. This might be obvious to you, but just thought I'd mention it anyways since I think it would be really useful.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • R0J0hound there's a minor bug when you try to alter the mass of an object with a polygon collision shape. Not a biggie, the workaround is to set coll shape to box before setting mass, then switching it back to polygon afterwards.

    Here's the error message:

  • help helP!!! i cant figure out how to stick to seperate sprites to each other when they both have physics enabled?? like a helmet on a head stuck, both sharing same rotation an angle? Simple but theres no way and not sure what joint to use.... should i make objects like that immovable and simply set the angle? but what if i need to to interact with normal collisions also? whats the physics way to do it???

  • jeebroniz here's what rojo said about the joint part of your question:

    [quote:2o3yi1ny]According to the chipmunk forums the way to join two objects together is with two joints. A pivot and a gear joint. I apologize fo the seeminly complicated formula used for the phase of the gear joint. It's the signed angle difference between the two object angles. angle(0,0,cos(a-b),sin(a-b))

    This is the capx he posted:

    The easy way to disable collisions between the two objects while still keeping their physics collisions with other objects active is to set their collision group property to the same non-zero value.

  • jeebroniz here's what rojo said about the joint part of your question:

    [quote:b72y9s4y]According to the chipmunk forums the way to join two objects together is with two joints. A pivot and a gear joint. I apologize fo the seeminly complicated formula used for the phase of the gear joint. It's the signed angle difference between the two object angles. angle(0,0,cos(a-b),sin(a-b))

    This is the capx he posted:

    The easy way to disable collisions between the two objects while still keeping their physics collisions with other objects active is to set their collision group property to the same non-zero value.

    wow man thanks a ton! , i totally forgot about the obviouys X and Y joint I had used previously to get more rigid hinges..

    now i wonder how most people approach AI using a physics enabled environment?

  • Prominent

    I hadn't anticipated that case where a joint still affects a disabled object. I guess I may need to remove the object further from the sim, as right now it just is removed from the simulation space. To be able to disable joints would also need some some work, since it's not nearly as straightforward as disabling objects is now. This will have to wait until I get to re-reviewing the code.

    mattb

    Thanks for the bug report as always. I haven't touched the code for a bit so I need to re-familiarize myself with it. Well, that and I need to then rework a lot of it to address the requests and feature requests of the last few pages. I'll see if I can make some time this week perhaps.

  • R0J0hound

    Prominent

    argh

    Any idea how to handle damping with a force-based magnet/point attractor so that attracted objects don't overshoot & fly around the centre? I've tried a bunch of expressions where force decreases towards the centre, with an opposing damping force based on velocity, & nothing works.

    The current method I'm using sets velocity directly, & it's fine until stuff gets dragged through walls. I'm hoping that forces will solve this, since they're always the recommended way of moving things in physics engines.

    https://dl.dropboxusercontent.com/u/523 ... oblem.webm

  • To dampen the velocity of an object that has forces applied, I think you could just multiply the velocity by something like 0.95 (or a value near 1) every 0.01 seconds or something like that..

    To help prevent objects sticking into other objects, you could try moving it out at the angle of the collision's normal a distance of the collision's depth(or maybe it's the negative of the depth?).. You'd get these values on post collision and perform the move then.

    That is what I would try.

    edit: btw, thanks for the info r0j0hound , I kind of thought it might require a lot of editing, but figured I'd mention it anyways in-case you ever see an opportunity to try it.

  • Prominent

    Yeah i've been doing that kind of velocity damping. I want to see if a force only approach is possible, to see if that improves collisions.

    Here's a comparison of velocity vs force based magnets (very simple with no falloff or damping, just constant velocity & force applied) to show how much better collls are when you don't mess with velocity:

    https://dl.dropboxusercontent.com/u/523 ... rison.capx

    EDIT: I think i've cracked it - damping force just needs to be a force opposing the object's angle of motion (chipmunk has an expression for that), proportional to its speed. Throw in a multiplier, negate gravity & it seems to be good, perfect collisions.

    new capx - https://dl.dropboxusercontent.com/u/523 ... mping.capx

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