Weld Joint Problem With Rotating Body
Posted: Fri Mar 14, 2014 11:05 am
Hi iforce,
I'm trying to set up a Box2D program with one circular rotating body, and another circular body that moves towards it and sticks to the first body's edge. The problem I'm having is that after I create a weld joint between the bodies, the second body tends to jump around erratically before the joint resolves itself.
The first body is a dynamic body with a circle fixture, connected to a static body with no fixtures by a revolute joint. It is able to rotate freely but not change position. The second body also has a circle fixture, and can move position freely. I use a b2ContactListener subclass to check for the collision. Then add a weld joint between the bodies, at the second body's centre, in the timestep immediately following the collision. The second body then jumps around for a few frames before the joint resolves itself at the correct position.
If I use a distance joint I don't get this problem. However, that means that the second body is able to spin on the first bodies edge. I want the second body to be in a fixed rotation relative to the first body, so I have to use a weld joint. Any ideas how I can solve this problem? Thanks for reading this.
Cheers
I'm trying to set up a Box2D program with one circular rotating body, and another circular body that moves towards it and sticks to the first body's edge. The problem I'm having is that after I create a weld joint between the bodies, the second body tends to jump around erratically before the joint resolves itself.
The first body is a dynamic body with a circle fixture, connected to a static body with no fixtures by a revolute joint. It is able to rotate freely but not change position. The second body also has a circle fixture, and can move position freely. I use a b2ContactListener subclass to check for the collision. Then add a weld joint between the bodies, at the second body's centre, in the timestep immediately following the collision. The second body then jumps around for a few frames before the joint resolves itself at the correct position.
If I use a distance joint I don't get this problem. However, that means that the second body is able to spin on the first bodies edge. I want the second body to be in a fixed rotation relative to the first body, so I have to use a weld joint. Any ideas how I can solve this problem? Thanks for reading this.
Cheers