Realistic top down movements?

Official forum for the Chipmunk2D Physics Library.
Post Reply
Jenny
Posts: 2
Joined: Wed Mar 31, 2010 3:58 am
Contact:

Realistic top down movements?

Post 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?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Realistic top down movements?

Post 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.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests