Page 1 of 1

Reversing Torque To Move in the Other Direction

Posted: Wed Oct 28, 2009 6:33 pm
by zacware
OK, surely a stupid question, as I'm new to chipmunk and haven't touched physics since college, but I've just finished my first game on the iphone using ChipMunk, and the one problem I'm having is having my car move LESS realistically.

I'm apply torque to the front and rear wheels, which have spring and pin joints attaching them to the body, and the car moves great, but when the user wants to go in the opposite direction, the car is slowing down first and then slowly accelerating in the opposite direction.

In the real world, this is how it would be, but this is a game, so I'm trying to get a less realistic response and have the car move in the opposite direction more quickly.

I've tried applying a temporary large negative torque in the opposite direction, but the wheels jump off the car in a ragdoll like fashion

I searched for what I assumed would be a common question, but it appears not to be the case. anyone have any pointers on this for a newbie?

Re: Reversing Torque To Move in the Other Direction

Posted: Wed Oct 28, 2009 9:32 pm
by mobilebros
I had a similar issue, I wanted to slow down a user controlled ball quickly if the opposite direction was desired. I ended up setting the horizontal velocity and angular velocity manually. In my game loop I detected the direction changed then did something like this:

Code: Select all

		body->v = cpv((body->v.x*0.75),body->v.y);
		body->w = body->w*0.75;

Re: Reversing Torque To Move in the Other Direction

Posted: Thu Oct 29, 2009 4:11 am
by zacware
Thanks! I'll try that!