/// <summary> /// Casts a ray downwards from the given kart /// </summary> /// <returns>The ray result callback</returns> private DynamicsWorld.ClosestRayResultCallback CastRay(Kart kart, float rayLength, DiscreteDynamicsWorld world) { // get a ray pointing downwards from the kart (-Y axis) Vector3 from = kart.ActualPosition + kart.ActualOrientation.YAxis; // have to move it up a bit Vector3 to = from - kart.ActualOrientation.YAxis * (rayLength + 1); // add 1 to compensate for the "moving up" we did to the "from" vector // make our ray var callback = new DynamicsWorld.ClosestRayResultCallback(from, to); // we only want the ray to collide with the environment and nothing else callback.CollisionFilterMask = rayFilterGroup; world.RayTest(from, to, callback); #if DEBUG //MogreDebugDrawer.Singleton.DrawLine(from, to, ColourValue.Red); #endif return callback; }