Bug in constraints between two bodies when one of the bodies is constrained to static or hits static.
See original GitHub issueHi,
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:
- Created 7 years ago
- Comments:16 (4 by maintainers)
Top GitHub Comments
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.@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).
Would appreciate if you could log any bugs on this too.