void Update()
    {
        if (!canTrackNow)
        {
            return;
        }

        if (!rccCamera)
        {
            rccCamera = GameObject.FindObjectOfType <RCC_Camera> ();
            return;
        }

        if (!currentCar)
        {
            currentCar = rccCamera.playerCar;
            return;
        }

        CheckCulling();

        distance = Vector3.Distance(transform.position, currentCar.position);
        rccCamera.targetFieldOfView = Mathf.Lerp(maximumFOV, minimumFOV, distance / maxDistance);
        transform.LookAt(currentCar.position);
    }
    /// <summary>
    /// Set Customization Mode. This will enable / disable controlling the car, and enable / disable orbit camera mode.
    /// </summary>
    public static void SetCustomizationMode(RCC_CarControllerV3 car, bool state)
    {
        if (!car)
        {
            Debug.LogError("Player Car is not selected for customization!");
            return;
        }

        if (state)
        {
            car.canControl = false;

            if (GameObject.FindObjectOfType <RCC_Camera> ())
            {
                RCC_Camera cam = GameObject.FindObjectOfType <RCC_Camera> ();
                cam.ChangeCamera(RCC_Camera.CameraMode.ORBIT);
                cam.useOnlyWhenHold = true;
            }
        }
        else
        {
            SetSmokeParticle(car, false);
            SetExhaustFlame(car, false);
            car.canControl = true;

            if (GameObject.FindObjectOfType <RCC_Camera> ())
            {
                GameObject.FindObjectOfType <RCC_Camera> ().ChangeCamera(RCC_Camera.CameraMode.TPS);
                GameObject.FindObjectOfType <RCC_Camera> ().useOnlyWhenHold = false;
            }
        }
    }
    void LateUpdate()
    {
        if (!canTrackNow)
        {
            return;
        }

        if (!rccCamera)
        {
            rccCamera = GameObject.FindObjectOfType <RCC_Camera> ();
            return;
        }

        if (!currentCar)
        {
            currentCar = rccCamera.playerCar;
            return;
        }

        CheckCulling();

        targetPosition  = currentCar.position;
        targetPosition += currentCar.rotation * Vector3.forward * (currentCar.GetComponent <RCC_CarControllerV3>().speed * .05f);

        smoothedPosition = Vector3.Lerp(smoothedPosition, targetPosition, Time.deltaTime * 5f);

        distance = Vector3.Distance(transform.position, currentCar.position);
        rccCamera.targetFieldOfView = Mathf.Lerp(distance > maxDistance / 10f ? maximumFOV : 70f, minimumFOV, (distance * 1.5f) / maxDistance);

        transform.LookAt(smoothedPosition);

        transform.Translate((-currentCar.forward * currentCar.GetComponent <RCC_CarControllerV3>().speed) / 50f * Time.deltaTime);
    }
    void Update()
    {
        // If RCC Camera is not selected in Inspector Panel, create it.
        if (!rccCamera)
        {
            rccCamera = GameObject.FindObjectOfType <RCC_Camera> ();
            return;
        }

        // If current car is null, get it from RCC Camera.
        if (!currentCar)
        {
            currentCar = rccCamera.playerCar;
            return;
        }

        // Rotates smoothly towards to car.
        transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(transform.eulerAngles.x, currentCar.transform.eulerAngles.y + 180, transform.eulerAngles.z), Time.deltaTime * 3f);

        // Calculating target position.
        targetPosition  = currentCar.position;
        targetPosition -= transform.rotation * Vector3.forward * 10f;

        // Assigning transform.position to targetPosition.
        transform.position = targetPosition;
    }
Beispiel #5
0
    public RCC_Camera RCCCamera;                                                             // Enabling / disabling camera selection script on RCC Camera if choosen.

    void Start()
    {
        if (!RCCCamera)
        {
            RCCCamera = GameObject.FindObjectOfType <RCC_Camera> ();
        }

        // First, we are instantiating all vehicles and store them in _spawnedVehicles list.
        CreateVehicles();
    }
Beispiel #6
0
    public void SetCameraSettings()
    {
        RCC_Camera cam = GameObject.FindObjectOfType <RCC_Camera>();

        if (!cam)
        {
            return;
        }

        cam.distance = distance;
        cam.height   = height;
    }
Beispiel #7
0
    public void SetCameraSettings()
    {
        RCC_Camera cam = RCC_SceneManager.Instance.activePlayerCamera;

        if (!cam)
        {
            return;
        }

        cam.TPSDistance = distance;
        cam.TPSHeight   = height;
    }
    private RayHitComparer m_RayHitComparer;      // variable to compare raycast hit distances


    private void Start()
    {
        // find the camera in the object hierarchy
        RCCCam         = GetComponent <RCC_Camera> ();
        m_Cam          = GetComponentInChildren <Camera>().transform;
        m_Pivot        = RCCCam.pivot.transform;
        m_OriginalDist = m_Cam.localPosition.magnitude;
        m_CurrentDist  = m_OriginalDist;

        // create a new RayHitComparer
        m_RayHitComparer = new RayHitComparer();
    }
    /// <summary>
    /// Repair Car.
    /// </summary>
    public static void SetCameraOrbitOnDrag(BaseEventData data)
    {
        RCC_Camera cam = GameObject.FindObjectOfType <RCC_Camera> ();

        if (!cam)
        {
            return;
        }

        if (cam.cameraMode != RCC_Camera.CameraMode.ORBIT)
        {
            cam.ChangeCamera(RCC_Camera.CameraMode.ORBIT);
        }

        cam.useOnlyWhenHold = true;

        cam.OnDrag(data);
    }
Beispiel #10
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);
            }
        }
    }
Beispiel #11
0
    IEnumerator GetVariables()
    {
        yield return(new WaitForSeconds(1));

        childCams = GetComponentsInChildren <RCC_ChildFixedCamera>();
        rccCamera = GameObject.FindObjectOfType <RCC_Camera>();

        foreach (RCC_ChildFixedCamera l in childCams)
        {
            l.enabled = false;
            l.player  = player;
        }

        camPositions   = new Transform[childCams.Length];
        childDistances = new float[childCams.Length];

        for (int i = 0; i < camPositions.Length; i++)
        {
            camPositions[i]   = childCams[i].transform;
            childDistances[i] = childCams[i].distance;
        }
    }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        RCCCam   = (RCC_Camera)target;
        orgColor = GUI.color;

        EditorGUILayout.Space();
        EditorGUILayout.HelpBox("Main Camera designed for RCC. It includes 7 different camera modes. It doesn't use many cameras for different modes like *other* assets. Just one single camera handles them.", MessageType.Info);
        EditorGUILayout.Space();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        EditorGUILayout.Space();
        EditorGUILayout.PropertyField(serializedObject.FindProperty("playerCar"), new GUIContent("Player Car", "Player Car."), false);
        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        EditorGUILayout.Space();
        EditorGUILayout.PropertyField(serializedObject.FindProperty("pivot"), new GUIContent("Pivot of the Camera", "Pivot of the Camera."), false);
        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();

        EditorGUILayout.Space();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        EditorGUILayout.Space();
        EditorGUILayout.PropertyField(serializedObject.FindProperty("cameraMode"), new GUIContent("Current Camera Mode", "Current Camera Modes."), false);
        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();

        EditorGUILayout.Space();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        EditorGUILayout.LabelField("TPS", EditorStyles.boldLabel);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("TPSDistance"), new GUIContent("TPS Distance", "TPS Distance."), false);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("TPSHeight"), new GUIContent("TPS Height", "TPS Height."), false);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("TPSHeightDamping"), new GUIContent("TPS Height Damping", "TPS Height Damping."), false);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("TPSRotationDamping"), new GUIContent("TPS Rotation Damping", "TPS Rotation Damping."), false);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("TPSMinimumFOV"), new GUIContent("TPS Minimum FOV", "TPS Minimum FOV."), false);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("TPSMaximumFOV"), new GUIContent("TPS Maximum FOV", "TPS Maximum FOV."), false);
        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();

        EditorGUILayout.Space();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        EditorGUILayout.LabelField("FPS", EditorStyles.boldLabel);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("useHoodCameraMode"), new GUIContent("Use Hood Camera Mode", "Shall we use Hood Camera Mode?"), false);

        if (RCCCam.useHoodCameraMode)
        {
            EditorGUILayout.HelpBox("Be sure your car has ''Hood Camera''. Camera will be parented to this gameobject. You can create it from Tools --> BCG --> RCC --> Camera Systems --> Add Hood Camera.", MessageType.Info);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("hoodCameraFOV"), new GUIContent("Hood Camera FOV", "Hood Camera FOV."), false);
        }

        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();

        EditorGUILayout.Space();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        EditorGUILayout.LabelField("Wheel", EditorStyles.boldLabel);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("useWheelCameraMode"), new GUIContent("Use Wheel Camera Mode", "Shall we use Wheel Camera Mode?"), false);

        if (RCCCam.useWheelCameraMode)
        {
            EditorGUILayout.HelpBox("Be sure your car has ''Wheel Camera''. Camera will be parented to this gameobject. You can create it from Tools --> BCG --> RCC --> Camera Systems --> Add Wheel Camera.", MessageType.Info);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("wheelCameraFOV"), new GUIContent("Wheel Camera FOV", "Wheel Camera FOV."), false);
        }

        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();

        EditorGUILayout.Space();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        EditorGUILayout.LabelField("Fixed", EditorStyles.boldLabel);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("useFixedCameraMode"), new GUIContent("Use Fixed Camera Mode", "Shall we use Fixed Camera Mode?"), false);

        if (RCCCam.useFixedCameraMode)
        {
            EditorGUILayout.HelpBox("Fixed Camera is overrided by ''Fixed Camera System'' on your scene.", MessageType.Info);

            EditorGUILayout.Space();

            if (!GameObject.FindObjectOfType <RCC_FixedCamera> ())
            {
                GUI.color = Color.green;

                if (GUILayout.Button("Create Fixed Camera System"))
                {
                    GameObject fixedCamera = new GameObject("RCC_FixedCamera");
                    fixedCamera.transform.position = Vector3.zero;
                    fixedCamera.transform.rotation = Quaternion.identity;
                    fixedCamera.AddComponent <RCC_FixedCamera> ();
                    RCC_LabelEditor.SetIcon(fixedCamera, RCC_LabelEditor.LabelIcon.Orange);
                }
            }
            else
            {
                GUI.color = orgColor;

                if (GUILayout.Button("Select Fixed Camera System"))
                {
                    Selection.activeGameObject = GameObject.FindObjectOfType <RCC_FixedCamera> ().gameObject;
                }
            }

            GUI.color = orgColor;
        }

        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();

        EditorGUILayout.Space();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        EditorGUILayout.LabelField("Cinematic", EditorStyles.boldLabel);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("useCinematicCameraMode"), new GUIContent("Use Cinematic Camera Mode", "Shall we use Cinematic Camera Mode?"), false);

        if (RCCCam.useCinematicCameraMode)
        {
            EditorGUILayout.HelpBox("Cinematic Camera is overrided by ''Cinematic Camera System'' on your scene.", MessageType.Info);

            EditorGUILayout.Space();

            if (!GameObject.FindObjectOfType <RCC_CinematicCamera> ())
            {
                GUI.color = Color.green;

                if (GUILayout.Button("Create Cinematic Camera System"))
                {
                    GameObject cinematicCamera = GameObject.Instantiate(RCC_Settings.Instance.cinematicCamera, Vector3.zero, Quaternion.identity) as GameObject;
                    RCC_LabelEditor.SetIcon(cinematicCamera, RCC_LabelEditor.LabelIcon.Orange);
                }
            }
            else
            {
                GUI.color = orgColor;

                if (GUILayout.Button("Select Cinematic Camera System"))
                {
                    Selection.activeGameObject = GameObject.FindObjectOfType <RCC_CinematicCamera> ().gameObject;
                }
            }

            GUI.color = orgColor;
        }

        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();
        EditorGUILayout.Space();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        EditorGUILayout.LabelField("Orbit", EditorStyles.boldLabel);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("useOrbitCameraMode"), new GUIContent("Use Orbit Camera Mode", "Shall we use Orbit Camera Mode?"), false);

        if (RCCCam.useOrbitCameraMode)
        {
            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(serializedObject.FindProperty("orbitXSpeed"), new GUIContent("Orbit X Speed", "Orbit X Speed."), false);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("orbitYSpeed"), new GUIContent("Orbit Y Speed", "Orbit Y Speed."), false);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("minOrbitY"), new GUIContent("Min Orbit Y", "Min Orbit Y."), false);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("maxOrbitY"), new GUIContent("Max Orbit Y", "Max Orbit Y."), false);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("orbitCameraFOV"), new GUIContent("Orbit Camera FOV", "Orbit Camera FOV."), false);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("useSmoothOrbit"), new GUIContent("Use Smooth Orbit", "Use Smooth Orbit."), false);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("useOnlyWhenHold"), new GUIContent("Use Only When Hold", "Use Only When Hold."), false);

            GUI.color = orgColor;
        }

        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();

        EditorGUILayout.Space();

        EditorGUILayout.BeginVertical(GUI.skin.box);
        EditorGUILayout.LabelField("Top-Down", EditorStyles.boldLabel);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("useTopCameraMode"), new GUIContent("Use Top Camera Mode", "Shall we use Top Camera Mode?"), false);

        if (RCCCam.useTopCameraMode)
        {
            EditorGUILayout.PropertyField(serializedObject.FindProperty("useOrthoForTopCamera"), new GUIContent("Use Ortho Mode", "Use Ortho Mode."), false);
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("topCameraDistance"), new GUIContent("Top Camera Distance", "Top Camera Distance"), false);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("topCameraAngle"), new GUIContent("Top Camera Angle", "Top Camera Angle"), false);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("maximumZDistanceOffset"), new GUIContent("Top Camera Maximum Z Distance", "Top Camera Maximum Z Distance"), false);

            if (RCCCam.useOrthoForTopCamera)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("minimumOrtSize"), new GUIContent("Minimum Ortho Size", "Minimum Ortho Size related with car speed."), false);
                EditorGUILayout.PropertyField(serializedObject.FindProperty("maximumOrtSize"), new GUIContent("Maximum Ortho Size", "Maximum Ortho Size related with car speed."), false);
            }
            else
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("minimumOrtSize"), new GUIContent("Minimum FOV", "Minimum FOV related with car speed."), false);
                EditorGUILayout.PropertyField(serializedObject.FindProperty("maximumOrtSize"), new GUIContent("Maximum FOV", "Maximum FOV related with car speed."), false);
            }
        }

        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();

        EditorGUILayout.Space();

        GUI.color = Color.red;

        if (GUILayout.Button("Reset To Detault Settings"))
        {
            UnityEditorInternal.ComponentUtility.CopyComponent(RCC_Settings.Instance.RCCMainCamera);
            UnityEditorInternal.ComponentUtility.PasteComponentValues(RCCCam);

            RCCCam.pivot = RCCCam.transform.Find("Pivot").gameObject;
        }

        EditorGUILayout.Space();

        GUI.color = orgColor;

        serializedObject.ApplyModifiedProperties();
    }
Beispiel #13
0
 void RCC_Camera_OnBCGCameraSpawned(GameObject BCGCamera)
 {
     activePlayerCamera = BCGCamera.GetComponent <RCC_Camera>();
 }
 void Start()
 {
     rccCamera = GameObject.FindObjectOfType <RCC_Camera> ();
 }