Esempio n. 1
0
    private void OnDrawGizmos()
    {
        ////DEBUGGING////

        if (debugWeight)
        {
            //Points of interest
            HelperMath.DebugDrawCross(transform, steerAngleLocationFront, 0.1f, Color.white, 0);
            HelperMath.DebugDrawCross(transform, steerAngleLocationRear, 0.1f, Color.white, 0);
            HelperMath.DebugDrawCross(transform, rBody.centerOfMass, 0.1f, Color.magenta, 0);
        }



        for (int i = 0; i < wheels.Length; i++)
        {
            if (debugStopPoints)
            {
                //Stop Position
                HelperMath.DebugDrawCross(wheels[i].stopPosWorld, 0.1f, Color.blue, 0);
                HelperMath.DebugDrawCross(wheels[i].wheelPivot.position, 0.1f, Color.magenta, 0);

                //Wheel trail
                HelperMath.DebugDrawCross(wheels[i].lastWorldPoses[1], 0.03f, Color.Lerp(Color.yellow, Color.red, 0.333f), 0);
                HelperMath.DebugDrawCross(wheels[i].lastWorldPoses[2], 0.03f, Color.Lerp(Color.yellow, Color.red, 0.666f), 0);
                HelperMath.DebugDrawCross(wheels[i].lastWorldPoses[3], 0.03f, Color.red, 0);
            }

            if (debugSuspension)
            {
                //Suspension info
                Color gripColor = Color.magenta;
                if (wheels[i].gripMult >= 1)
                {
                    gripColor = Color.Lerp(Color.black, Color.green, Mathf.Clamp01(wheels[i].gripMult - 1));
                }
                else
                {
                    gripColor = Color.Lerp(Color.red, Color.black, Mathf.Clamp01(wheels[i].gripMult));
                }
                Debug.DrawRay(wheels[i].wheelCastPoint.position - transform.up * wheels[i].wheelRadius, wheels[i].rHit.normal * wheels[i].gripMult, gripColor, 0, false);
            }

            if (debugRaycast)
            {
                HelperMath.DebugDrawCross(wheels[i].rHit.point, 0.1f, Color.green, 0);
                HelperMath.DebugDrawCross(wheels[i].wheelCastPoint.position + -wheels[i].wheelCastPoint.up * sRestDistance, 0.05f, Color.white, 0);
                Debug.DrawRay(wheels[i].wheelCastPoint.position, -wheels[i].wheelCastPoint.up * sMaxDistance, Color.green, 0, false);
            }
        }
    }