コード例 #1
0
    IEnumerator StopVehicle(float WaitTime, bool SetNextNode)
    {
        CurrentBrakeTorque             = MaxTorque;
        WheelColliders [0].brakeTorque = CurrentBrakeTorque;
        WheelColliders [1].brakeTorque = CurrentBrakeTorque;
        WheelColliders [2].brakeTorque = CurrentBrakeTorque;
        WheelColliders [3].brakeTorque = CurrentBrakeTorque;
        foreach (GameObject HL in BackLights) //Get every backlight from the backlights array
        {
            HL.SetActive(true);               //Set them as active
        }
        RpcRemoteStopVehicle(CurrentBrakeTorque, true);
        yield return(new WaitForSeconds(WaitTime));         //Stop time

        if (SetNextNode == true)
        {
            CurrentNode = CurrentNode.GetComponent <PathFinder> ().NextNodes [Random.Range(0, CurrentNode.GetComponent <PathFinder> ().NextNodes.Count)]; //Get the next node
        }
        isBraking = false;                                                                                                                                //We dont need to be braking anymore
        foreach (GameObject HL in BackLights)                                                                                                             //Get every backlight from the backlights array
        {
            HL.SetActive(false);                                                                                                                          //Set them as active
        }
        CurrentBrakeTorque = 0f;
        //Apply the brake torque on all wheels
        WheelColliders [0].brakeTorque = CurrentBrakeTorque;
        WheelColliders [1].brakeTorque = CurrentBrakeTorque;
        WheelColliders [2].brakeTorque = CurrentBrakeTorque;
        WheelColliders [3].brakeTorque = CurrentBrakeTorque;
        RpcRemoteStopVehicle(CurrentBrakeTorque, false);
    }
コード例 #2
0
 public void RpcRemoteStopVehicle(float brakeTorque, bool BackLight)     //Apply the braketorque and backlights stance to all clients so braking looks better and other clients can see the brake lights on traffic vehicles
 {
     WheelColliders [0].brakeTorque = brakeTorque;
     WheelColliders [1].brakeTorque = brakeTorque;
     WheelColliders [2].brakeTorque = brakeTorque;
     WheelColliders [3].brakeTorque = brakeTorque;
     foreach (GameObject HL in BackLights)     //Get every backlight from the backlights array
     {
         HL.SetActive(BackLight);              //Invert the current stance of the brakelights
     }
 }