Car Moving Hap hazardly

Post about the Flash World Construction Kit and the Alchemy port of Box2D.
jinisner
Posts: 146
Joined: Tue Apr 17, 2012 12:08 am

Car Moving Hap hazardly

Postby jinisner » Sat May 11, 2013 6:10 am

Hi,

I am trying to simulate a situation where the car need to jump from one block to another, for this the car comes at a speed and jump over a ramp , i use the below code to give car the speed...

level1World1.car1.b2body.ApplyImpulse(new V2(1, 0), level1World1.car1.b2body.GetWorldCenter());

but the car gains too much speed and almost starts to fly , is there a way i can define the gradual speed at which the car can move and then reach a max speed and not go beyond it ...

Thanks in advance ...

Regards
Jin

jinisner
Posts: 146
Joined: Tue Apr 17, 2012 12:08 am

Re: Car Moving Hap hazardly

Postby jinisner » Sun May 12, 2013 11:25 pm

Hi,

I tried setting the linear velocity like this -

level1World.car.linearVelocityX=2.4;

but the vehicle now moves at a fixed speed, is there any other way ...

thanking you in advance ....

Regards
Jin

irresistible force
Posts: 1991
Joined: Tue Jun 24, 2008 8:25 pm
Location: Tokyo
Contact:

Re: Car Moving Hap hazardly

Postby irresistible force » Mon May 13, 2013 2:22 am

How about checking the velocity of the car, and applying less impulse depending on how fast it's moving. If it's already moving at the maximum speed you want, then the impulse would be zero.

jinisner
Posts: 146
Joined: Tue Apr 17, 2012 12:08 am

Re: Car Moving Hap hazardly

Postby jinisner » Tue May 14, 2013 11:54 pm

@irrestibleforce - thanks a lot, that worked ...

Regards
Jin


Return to “WCK”



Who is online

Users browsing this forum: No registered users and 2 guests