// Deactivates selected vehicle and returns to the car selection.
    public void DeSelectVehicle()
    {
        // De-registers the vehicle.
        RCC.DeRegisterPlayerVehicle();

        // Resets position and rotation.
        _spawnedVehicles[selectedIndex].transform.position = spawnPosition.position;
        _spawnedVehicles[selectedIndex].transform.rotation = spawnPosition.rotation;

        // Kills engine and disables controllable.
        _spawnedVehicles[selectedIndex].KillEngine();
        _spawnedVehicles[selectedIndex].SetCanControl(false);

        // Resets the velocity of the vehicle.
        _spawnedVehicles[selectedIndex].GetComponent <Rigidbody>().ResetInertiaTensor();
        _spawnedVehicles[selectedIndex].GetComponent <Rigidbody>().velocity        = Vector3.zero;
        _spawnedVehicles[selectedIndex].GetComponent <Rigidbody>().angularVelocity = Vector3.zero;

        // If RCC Camera is choosen, it wil enable RCC_CameraCarSelection script. This script was used for orbiting camera.
        if (RCCCamera)
        {
            if (RCCCamera.GetComponent <RCC_CameraCarSelection>())
            {
                RCCCamera.GetComponent <RCC_CameraCarSelection>().enabled = true;
            }
        }
    }
示例#2
0
 public void DeRegisterPlayer()
 {
     // Deregisters the vehicle from as player vehicle.
     RCC.DeRegisterPlayerVehicle();
 }