void Start()
    {
        // Getting RCC, wheelcolliders, rigidbody, and Network Identity of the vehicle.
        carController  = GetComponent <RCC_CarControllerV3>();
        wheelColliders = GetComponentsInChildren <RCC_WheelCollider> ();
        rigid          = GetComponent <Rigidbody>();
        networkID      = GetComponent <NetworkIdentity> ();

        // If we are the owner of this vehicle, disable external controller and enable controller of the vehicle. Do opposite if we don't own this.
        if (isLocalPlayer)
        {
            carController.externalController = false;
            carController.SetCanControl(true);
        }
        else
        {
            carController.externalController = true;
            carController.SetCanControl(false);
        }

        // Setting name of the gameobject with Network ID.
        gameObject.name = gameObject.name + networkID.netId;

        currentVehicleTransform = new VehicleTransform();
    }
Example #2
0
    /// <summary>
    /// Set Customization Mode. This will enable / disable controlling the vehicle, and enable / disable orbit camera mode.
    /// </summary>
    public static void SetCustomizationMode(RCC_CarControllerV3 vehicle, bool state)
    {
        if (!vehicle)
        {
            Debug.LogError("Player vehicle is not selected for customization! Use RCC_Customization.SetCustomizationMode(playerVehicle, true/false); for enabling / disabling customization mode for player vehicle.");
            return;
        }

        RCC_Camera             cam = RCC_SceneManager.Instance.activePlayerCamera;
        RCC_UIDashboardDisplay UI  = RCC_SceneManager.Instance.activePlayerCanvas;

        if (state)
        {
            vehicle.SetCanControl(false);

            if (cam)
            {
                cam.ChangeCamera(RCC_Camera.CameraMode.TPS);
            }

            if (UI)
            {
                UI.SetDisplayType(RCC_UIDashboardDisplay.DisplayType.Customization);
            }
        }
        else
        {
            SetSmokeParticle(vehicle, false);
            SetExhaustFlame(vehicle, false);
            vehicle.SetCanControl(true);

            if (cam)
            {
                cam.ChangeCamera(RCC_Camera.CameraMode.TPS);
            }

            if (UI)
            {
                UI.SetDisplayType(RCC_UIDashboardDisplay.DisplayType.Full);
            }
        }
    }
Example #3
0
    public void RegisterPlayer(RCC_CarControllerV3 playerVehicle, bool isControllable)
    {
        activePlayerVehicle = playerVehicle;
        activePlayerVehicle.SetCanControl(isControllable);

        ///if(activePlayerCamera)
        //activePlayerCamera.SetTarget (activePlayerVehicle.gameObject);

        //if (GameObject.FindObjectOfType<RCC_CustomizerExample> ())
        //	GameObject.FindObjectOfType<RCC_CustomizerExample> ().CheckUIs ();
    }
Example #4
0
    public void DeRegisterPlayer()
    {
        if (activePlayerVehicle)
        {
            activePlayerVehicle.SetCanControl(false);
        }

        activePlayerVehicle = null;

        //if (activePlayerCamera)
        //activePlayerCamera.RemoveTarget ();
    }
    void FixedUpdate()
    {
        // If we are the owner of this vehicle, disable external controller and enable controller of the vehicle. Do opposite if we don't own this.
        carController.externalController = !isLocalPlayer;
        carController.SetCanControl(isLocalPlayer);

        if (isLocalPlayer)
        {
            // If we are owner of this vehicle, stream all inputs from vehicle.
//			VehicleIsMein ();
            if (!CB_running)
            {
                StartCoroutine(VehicleIsMein());
            }
        }
        else
        {
            // If we are not owner of this vehicle, receive all inputs from server.
            VehicleIsClient();
        }
    }
Example #6
0
    ///<summary>
    /// Spawn a RCC vehicle prefab with given position, rotation, sets its controllable, and engine state.
    ///</summary>
    public static RCC_CarControllerV3 SpawnRCC(RCC_CarControllerV3 vehiclePrefab, Vector3 position, Quaternion rotation, bool registerAsPlayerVehicle, bool isControllable, bool isEngineRunning)
    {
        RCC_CarControllerV3 spawnedRCC = (RCC_CarControllerV3)GameObject.Instantiate(vehiclePrefab, position, rotation);

        spawnedRCC.gameObject.SetActive(true);
        spawnedRCC.SetCanControl(isControllable);

        if (registerAsPlayerVehicle)
        {
            RCC_SceneManager.Instance.RegisterPlayer(spawnedRCC);
        }

        if (isEngineRunning)
        {
            spawnedRCC.StartEngine(true);
        }
        else
        {
            spawnedRCC.KillEngine();
        }

        return(spawnedRCC);
    }
Example #7
0
 ///<summary>
 /// Sets controllable state of the vehicle.
 ///</summary>
 public static void SetControl(RCC_CarControllerV3 vehicle, bool isControllable)
 {
     vehicle.SetCanControl(isControllable);
 }