question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug in constraints between two bodies when one of the bodies is constrained to static or hits static.

See original GitHub issue

Hi,

Say we want to design a hat and the hat has that puffy dangling sphere on top.

As an example I have created a static body as an anchor. To the static body I have linked dynamic head/hat base body with 4 constraints to keep it in place. User can interact with head. And I added a debug body just to show that gravity works. To the dynamic head/hat base body I have linked dynamic puff body with 1 constraint to keep the puff constrained RELATIVELY to the hat. User can interact with the puff. So whenever user grabs and drags hat or puff, both follow.

See example http://jsbin.com/hazumud/10/edit?js,output

It behaves unexpectedly. Whenever I grab the hat body (largest circle) I expect the puff (top right) to follow (with “elastic dealy” of course as the puff has some inertia) as well as to puff dangle because there is gravity. However it seems it wants to stay in place in some absolute coordinate space. Why?

I thought


// this.circle2BodyDynamic is head puff
// this.circle1BodyDynamic is overall hat/head

    this.circle2ConstraintToCircle1 = Constraint.create({
      bodyA: this.circle2BodyDynamic,
      bodyB: this.circle1BodyDynamic,
      pointA: {x: 0, y: 0},
      pointB: {
        x: 80.0,
        y: -80.0
      },
      length: 1.0,
      stiffness: 0.5,
      label: 'circle2ConstraintToCircle1'
    });

would make this.circle2BodyDynamic (puff) relative to circle2ConstraintToCircle1 (head) wherever head goes, but it seems it isn’t, this.circle2BodyDynamic (puff) want’s to stay in place (it does follow a little bit, but the feeling is that there is yet another invisible constraint that wants to keep it back in the original position). And confusion grows, because there is gravity, puff should try to drop down, only thing holding it should be constraint to head, which itself is constrained to static.

As each Physics engine has its way of doing things, what would be the right way to make puff react to gravity and follow head (with inertia) wherever it goes as it would in real physics world?

Thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
krokocommented, Dec 20, 2016

In the end I somehow tamed the beast to get that head and puff working. I do appreciate the huge work put into this, but honestly 99% I had to work against the lib 😢 Meaning that the API is super great and super fast to code with!, the results are the ones that need to go back and start applying hacks all over the place. I mean, take n constraints and hang an object in it, so it settles. Some kind of swing. Swap the constraints in the world (order they are added). In Real world physics it does not matter, object settles in the same position. Here it matters. Kind of pun, right. 😄 There are also issues with events, especially touch. Anyways, thanks @liabru, I wish I had time instead of just bugreporting actually contribute to this. Happy holidays! @Technostalgic my “main” language is C++ and I have used Box2D ever so many times as well as Bullet and some misc verlet types (also in Processing/Java). There are glitches in B2D, but they are predictable.

0reactions
liabrucommented, Dec 21, 2016

@kroko I’m glad you got it working (it’s awesome!) and I apologise for the issues you had here. FYI I spent a number of hours on this over the past week on this issue and while I had a few promising results they failed for many other cases which made it unusable. I’ll still continue to investigate here so this will stay open (thanks for providing the examples).

There are also issues with events, especially touch.

Would appreciate if you could log any bugs on this too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prevent force-dragging bodies through other ... - Stack Overflow
In broad terms the way this works is to check if the body being dragged, dragBody , has collided with a static body...
Read more >
FREE BODY DIAGRAMS (FBDs)
Static Indeterminacy : occurs when a system has more constraints than is necessary to hold the system in equilibrium (i.e., the system is...
Read more >
Troubleshooting Common Physics Asset Errors
If a Physics Constraint is keeping the offending Physics Bodies together, the physics system will continually apply force to separate them, causing very...
Read more >
5.20: Matter.js: Constraints - The Nature of Code - YouTube
In this video, I show you how to you can create constraints to connect rigid bodies in matter.js (with p5.js).
Read more >
Bullet Constraints - LightWave 2020
All Constraints have an Enable Collision setting. When on, collision detection is enabled between the two bodies connected by the constraint. When two...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found