How do I make a physic rope/chain that have inertia?

0 favourites
  • 8 posts
  • Hey everyone. I try to make some kind of rope or chain with physics. The main idea is to pin one side of the rope to the car, and on the other side during gameplay to pin an object when you will make a hook, and after that when you drive, to make chain and object pinned to chain to move behind the car with inertia. And for example when the object or the chain chit an pbstacle to bounce of it. Applying Physic behavior do not work for me. Maybe this method of making chain is not a great choise? Maybe there are a better pethod to make a durable chain with stable physics and with colision with solids? Thank you very much!

    PS here is the c3p.

    filetransfer.io/data-package/2VCwFTkH

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Also forgot to ask. Here in the project, the chain is from the start in full length. What I need to do to make it grow in lenght and then to make it short again, I mean to simulate like you tighten the chain back?

  • It's a pretty cool example, but it won't work with solids or physics.

    You can make a chain with Physics:

    howtoconstructdemos.com/create-a-realistic-chain-or-rope-with-physics

    But note that Physics is not compatible with other behaviors like Pin or Solid. So you will need to use physics joints instead of Pin and immovable objects instead of solid.

  • It's a pretty cool example, but it won't work with solids or physics.

    You can make a chain with Physics:

    https://howtoconstructdemos.com/create-a-realistic-chain-or-rope-with-physics/

    But note that Physics is not compatible with other behaviors like Pin or Solid. So you will need to use physics joints instead of Pin and immovable objects instead of solid.

    This method works too, but there are some bugs, if the car have a bigger speed then the chain starts to broke, and also if I apply gravity to the world the chain will be always down,it have inertion but it is alwais directed down, if I apply gravity 0 the chain will go around the car but the inertion will dissapear.

    My goal is to make the chain stable and also to be able to apply inertion to the chain and hook depending by movement of the car for example:

    --- if the car goes forward then suddenly turns right, then the chain will go from inertia to the left and vice versa, and this regardless of the speed of the car and the weight of the hook. Also wanted to do that with physics because want to to make chain to bounce or to stop when it hits immovable objects etc etc.

    filetransfer.io/data-package/MXMuzXxb

  • Making a game with Physics is not an easy task. You need to be careful not to apply too much force to joints, or they will break. And you'll have to experiment with physics settings like density, friction etc. to get the movement right. To "calm down" the chain without gravity you can try increasing linear damping, or reduce velocity with events.

  • Sure I understand that. Will try to find out a solution, and if I will, I will post here the result. Thank you very much!

  • This may be a useful reference.

    betterprogramming.pub/making-a-verlet-physics-engine-in-javascript-1dff066d7bc5

    Notable difference to what you’re doing is when limiting the distance between nodes it takes the mass of each node into consideration.

    Another thought is to take mass into consideration when applying damping. Something like this:

    (X-px)- (1-damping)*(x-px)/mass

    For the gravity it looks like what you have is in line with verlet physics. You probably just need to use smaller gravity values.

    For collisions it would be a matter of pushing the nodes out of shapes in the closest direction. For circles it’s basically the same as what limits the distance between nodes. For a box it’s a bit more involved.

    You asked how to make it change length. Probably by changing the rest length. Adding/removing nodes on the fly seems like an interesting idea too but may take a bit more logic.

    As to make it more stable, you need more iterations. It’s trying to solve the limits one at a time so only the last one is perfect. Each iteration brings everything closer. Also the longer the chain is you’ll need more iterations.

    So you could limit the speeds of the player and enemy. Or if higher speeds are needed you could move over several smaller steps in a loop with that iteration loop to solve the limits.

  • Thank you very much. I will experiment with that and will see if that works for me :)

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