By the way, in general the method I've read uses a traceline down from each wheel. Then you simply determine the origins of the four hitpos, create a plane from that, and then get the normal of that plane and stick your car to it. This is, at least, how Midtown Madness 2's creators described their algorithm. As Sebastian said, getting the plane normal of the geometry below you is not sufficient.
After you've gotten the correct pitch and roll of your vehicle, you simply set the vehicle at the correct position (I don't think HL's default physics would be capable of handling an angled vehicle, but I dunno). You can also add some think function reinstating gravity if the tracelines go too far down (a la Laverne and Shirley). One question that presents itself to me is that three points are enough to define a plane, which means in turn that having four means you won't always get a plane. I would probably take the back two wheels as a roll reference, then use whichever front wheel had the smallest flFraction as the pitch reference. So, assuming our vectors are in vecWheel[4] going clockwise around the car from the rear left, and the fractions are in the same size array and order, you might want something like the following. Vector right = (vecWheel[3] - vecWheel[0]).Normalize(); If( flFraction[1] < flFraction[2] ) Vector forward = (vecWheel[1] - vecWheel[0]).Normalize(); Else Vector forward = (vecWheel[2] - vecWheel[3]).Normalize(); Vector up = CrossProduct( right, forward ); Then you have the three vectors of the correct vehicle axes. Then the pitch is arcsin(forward[2]), the roll is arcos( up[2] / cos( pitch ) ), and the yaw is arcos( forward[0] / cos( pitch ) ). At least... if my algebra from the AngleVectors function is correct. Anyway, hope that helps. That should get you going up and down hills for sure. I dunno about banking left and right. Persuter > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:hlcoders- > [EMAIL PROTECTED]] On Behalf Of botman > Sent: Friday, June 21, 2002 3:29 PM > To: [EMAIL PROTECTED] > Subject: Re: [hlcoders] vehicles > > > I guess you have to do the following: > > Do a traceline straight down to the ground at the front and at the back. > > Then see whether there's any difference in trace length (forget about a > few > > tenths, it's only whole units that make a difference). If there is, use > some > > triangle maths to calculate the angle of the slope. Once you got it, use > > this new angle to correct the vehicle's acceleration. > > The angle of the slope will come from the vecPlaneNormal field of the > UTIL_TraceLine() result. Just shove it into UTIL_VecToAngles() to convert > the > vector normal to an array of angles, then set the body angles of the > vehicle > entity to match. > > Jeffrey "botman" Broome > > _______________________________________________ > To unsubscribe, edit your list preferences, or view the list archives, > please visit: > http://list.valvesoftware.com/mailman/listinfo/hlcoders _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders

