Page 1 of 1

Realistic top down movements?

Posted: Wed Apr 21, 2010 2:22 am
by Jenny
Hi,

I want to make a top-down view of a truck/snake/train-like object. I took the example in the "Car simulation (top down) following a path" Topic:

http://www.slembcke.net/forums/viewtopi ... path#p4043

And added a "trailer" to the tank with this code in the init method:

Code: Select all

trailerBody = add_box(10.0, 2.0);
    cpConstraint *pivotTrailer;
    pivotTrailer = cpSpaceAddConstraint(space, cpPivotJointNew2(tankBody, trailerBody, cpv(-20,0), cpv(10,0)));
	pivotTrailer->biasCoef =0.1f; 
	pivotTrailer->maxForce = 10000.0f;	

Result was this:

Image

If the violet tank moves in a curve, like in the picture anti-clockwise, the blue box always hinges to the outside. I would have expected the opposite, that a object on a joint would lean to the inside of the curve?

Re: Realistic top down movements?

Posted: Wed Apr 21, 2010 8:54 am
by slembcke
All you've done is added a soft pin joint to pull the trailer towards the tank. In regards to the floor, it's completely frictionless. With no friction to pull the trailer back behind the tank, it will fly away from the center of the circle.

You need to add extra joints like the tank has holding it to the control body. Though because the trailer is not powered, you'd simply attach the joints from the trailer to the static body.