Game Development Community

Auto center wheels & forces

by Ryan Ackley · in Torque Game Engine · 03/15/2003 (5:02 pm) · 3 replies

A while back there was a post with a way to force wheeled vehicles to auto center their wheels ( i suppose it works for the other types, since its in vehicle.cc ), it goes along the lines of
// Steering   
   if (move != &NullMove)
      {
	        if(move->yaw )
			{
			        F32 y = move->yaw;
					mSteering.x = mClampF(mSteering.x + y,-mDataBlock->maxSteeringAngle,
					      mDataBlock->maxSteeringAngle);      
					F32 p = move->pitch;      
					mSteering.y = mClampF(mSteering.y + p,-mDataBlock->maxSteeringAngle,      
					      mDataBlock->maxSteeringAngle);
	      }      
		  else      
		  {      
				mSteering.x *= 0.7;
				mSteering.y *= 0.7;
				      
	     } 
	}   
	else   
	{      
	mSteering.x *= 0.7;
	mSteering.y *= 0.7;
	      
}

The wheels center themselves alright, but it seems that after making a turn, the forces from the turn cause the car to keep turning, though the wheels are pointed straight. I was thinking that updateforces() would help, but theres zero code in there. So anyone know why im still turning, even though the wheels are pointed straight? Is this just a hack on the animation? Any help is appreciated.
Ryan

#1
03/15/2003 (5:26 pm)
Hm, did a little playing around with this, and it seems that the car straightens out after a bit. Anyone know how i can stop the car from turning in that little bit after i stop turning? I tried setting the steering from gradual center to just zero to instantly be straight, but no dice. Tried forces on the tires to grip better, not there either. Any ideas? Thanks
Ryan
#2
03/16/2003 (8:36 am)
Your last ELSE

mSteering.x *= 0.7;
mSteering.y *= 0.7;

put this instead

mSteering.x = 0;
mSteering.y = 0;
#3
03/16/2003 (9:08 am)
Thanks man, that did it!
Ryan