A is a static body
B is a moving body being dragged around
P is a fixed position directly below A
When B hits A, I wish it to slide to P and stay there at exactly that spot.
Currently I'm implementing a collision handler between A & B which (after the step has completed) puts a GrooveJoint between the current position of B and position P with an anchor of zero.
About 80% of the time B correctly arrives at point P.
The other 10% B ends up offset either to the left, right or below...
I've looked a the velocity each time to see if going over a certain threshold appears to cause the problem, but it's pretty random.
I've tried putting a damped spring between B & P as well, but to no avail. I was wondering if anyone has any ideas of firstly what is going on, and secondly what I can do to fix it?
Code: Select all
CGPoint start = ccpSub(bodyB.pos, bodyA.pos);
CGPoint P = CGPointMake(0, -50);
ChipmunkGrooveJoint* grooveJoint = [ChipmunkGrooveJoint grooveJointWithBodyA:bodyB bodyB:bodyA groove_a:start groove_b:P anchr2:CGPointZero];
[space add:grooveJoint];