Exemple #1
0
    // ------------------------------------------------------------------------------
    // Name	:	SetupAntiRollBars
    // Desc	:	Pairs up and creates a anti roll bar for the wheels on each axis
    // ------------------------------------------------------------------------------
    private void SetupAntiRollBars()
    {
        antiRollBarList = new AntiRollBar[2];
        Wheel[] frontPair  = new Wheel[2];
        Wheel[] rearPair   = new Wheel[2];
        int     frontIndex = 0;
        int     rearIndex  = 0;

        // Divide the wheels into pairs that should be connected via anti roll bars
        foreach (Wheel w in wheels)
        {
            if (w.frontWheel)
            {
                frontPair[frontIndex++] = w;
            }
            else
            {
                rearPair[rearIndex++] = w;
            }
        }

        // Connect the wheels pair wise
        AntiRollBar arbFront = new AntiRollBar();

        arbFront.wheelL = frontPair[0];
        arbFront.wheelR = frontPair[1];

        AntiRollBar arbRear = new AntiRollBar();

        arbRear.wheelL = rearPair[0];
        arbRear.wheelR = rearPair[1];

        // Add the rigidid body of the car that the anti roll bars will add forces to
        arbFront.carRigidBody = MyRigidBody;
        arbRear.carRigidBody  = MyRigidBody;

        // Add the strength of the anti roll bars as set in the inspector
        arbFront.antiRollVal = antiRollBarStiffness;
        arbRear.antiRollVal  = antiRollBarStiffness;

        antiRollBarList[0] = arbFront;
        antiRollBarList[1] = arbRear;
    }
Exemple #2
0
    // ------------------------------------------------------------------------------
    // Name	:	SetupAntiRollBars
    // Desc	:	Pairs up and creates a anti roll bar for the wheels on each axis
    // ------------------------------------------------------------------------------
    private void SetupAntiRollBars()
    {
        antiRollBarList = new AntiRollBar[2];
        Wheel[] frontPair = new Wheel[2];
        Wheel[] rearPair = new Wheel[2];
        int frontIndex = 0;
        int rearIndex = 0;

        // Divide the wheels into pairs that should be connected via anti roll bars
        foreach (Wheel w in wheels)
        {
            if (w.frontWheel)
                frontPair[frontIndex++] = w;
            else
                rearPair[rearIndex++] = w;
        }

        // Connect the wheels pair wise
        AntiRollBar arbFront = new AntiRollBar();
        arbFront.wheelL = frontPair[0];
        arbFront.wheelR = frontPair[1];

        AntiRollBar arbRear = new AntiRollBar();
        arbRear.wheelL = rearPair[0];
        arbRear.wheelR = rearPair[1];

        // Add the rigidid body of the car that the anti roll bars will add forces to
        arbFront.carRigidBody = MyRigidBody;
        arbRear.carRigidBody = MyRigidBody;

        // Add the strength of the anti roll bars as set in the inspector
        arbFront.antiRollVal = antiRollBarStiffness;
        arbRear.antiRollVal = antiRollBarStiffness;

        antiRollBarList[0] = arbFront;
        antiRollBarList[1] = arbRear;
    }