@aybe : can only agree with Xpand.
About your hover issues : have you tried the following : when you shoot rays against the track, you do it against a special collision track 3D model that has only the "ground" track faces set (these faces have a special flag in the TRF file). These are the one that rise up/down quickly when you use the "Quake disruptor" weapon. Only these faces should be considered when calculating ship/floor distance or actual track orientation.
BTW, you consider ALL track faces when performing regular colisions, because you want don't want ship to go out the track.
To avoid issue with gaps : if a ray does not collide with anything, simply take the latest valid result (that you keep somewhere) :
Code:
if(ray.hit(..., out result))
{
lastValidHit = result;
}
else
{
//oops, there is a gap, take latest result
result = lastValidHit;
}
//do something here with "result"
...
or you might consider another approach : the idea is to always have a 3D track orientation for any given ship position. I supsect the original game to do something like that since it's quite easy to calculate. Not need to shoot rays. Here how to do : you loop trought all track sections, calculate the one which is the nearest from the ship (by calculating ship/section distance). Once you have the nearest section, you calculate the normal vector of that section (easy and could be precalculated before and stored). This is the actual track orientation and the one the ship should have. Even if the ship goes out off the track but continue moving forward) you still get a 3D orientation.
To avoid brutal changes, you can smooth that out using an interpolation method :
Code:
var orientation = to calculate...
smoothorientation = Quaternion.Slerp(smoothorientation, orientation, 0.7f); //between 0.0 and 1.0
instead of using 4 push forces, you might consider using only one (at center of gravity) and actually rotating the ship by simply applying a torque to the rigid body (so that the ship is always more or less oriented like the track).