void GetPlayerCar() { if (!playerCar) { return; } playerRigid = playerCar.GetComponent <Rigidbody>(); hoodCam = playerCar.GetComponentInChildren <RCCHoodCamera>(); wheelCam = playerCar.GetComponentInChildren <RCCWheelCamera>(); fixedCam = GameObject.FindObjectOfType <RCC_MainFixedCamera>(); transform.position = playerCar.transform.position; transform.rotation = playerCar.transform.rotation * Quaternion.Euler(10f, 0f, 0f); if (playerCar.GetComponent <RCC_CameraConfig>()) { playerCar.GetComponent <RCC_CameraConfig>().SetCameraSettings(); } // Quaternion orgRotation = playerCar.rotation; // playerCar.rotation = Quaternion.identity; // // Bounds combinedBounds = playerCar.GetComponentInChildren<Renderer>().bounds; // Renderer[] renderers = playerCar.GetComponentsInChildren<Renderer>(); // // foreach (Renderer render in renderers) { // if (render != playerCar.GetComponent<Renderer>() && render.GetComponent<ParticleSystem>() == null) // combinedBounds.Encapsulate(render.bounds); // } // // playerCar.rotation = orgRotation; // // boundCenter = new GameObject("Bounds Center"); // boundCenter.transform.position = combinedBounds.center; // boundCenter.transform.rotation = playerCar.rotation; // boundCenter.transform.SetParent(playerCar, true); }
public void ChangeCamera() { if (!target) { return; } cameraChangeCount++; if (cameraChangeCount >= 5) { cameraChangeCount = 0; } if (target.GetComponent <RCCCarCameraConfig>()) { dist = target.GetComponent <RCCCarCameraConfig>().distance; height = target.GetComponent <RCCCarCameraConfig>().height; carCamera.distance = dist; carCamera.height = height; } if (useOrbitCamera) { orbitScript.target = target.transform; orbitScript.distance = dist; } if (target.GetComponentInChildren <RCCCockpitCamera>()) { cockpitCamera = target.GetComponentInChildren <RCCCockpitCamera>(); } if (target.GetComponentInChildren <RCCWheelCamera>()) { wheelCamera = target.GetComponentInChildren <RCCWheelCamera>(); } switch (cameraChangeCount) { case 0: orbitScript.enabled = false; carCamera.enabled = true; carCamera.transform.parent = null; break; case 1: if (!useOrbitCamera) { ChangeCamera(); break; } orbitScript.enabled = true; carCamera.enabled = false; carCamera.transform.parent = null; break; case 2: if (!useFixedCamera) { ChangeCamera(); break; } orbitScript.enabled = false; carCamera.enabled = false; carCamera.transform.parent = null; break; case 3: orbitScript.enabled = false; carCamera.enabled = false; carCamera.transform.parent = target; if (!cockpitCamera) { ChangeCamera(); break; } carCamera.transform.localPosition = cockpitCamera.transform.localPosition; carCamera.transform.localRotation = cockpitCamera.transform.localRotation; carCamera.GetComponent <Camera>().fieldOfView = 60; break; case 4: orbitScript.enabled = false; carCamera.enabled = false; carCamera.transform.parent = target; if (!wheelCamera) { ChangeCamera(); break; } carCamera.transform.localPosition = wheelCamera.transform.localPosition; carCamera.transform.localRotation = wheelCamera.transform.localRotation; carCamera.GetComponent <Camera>().fieldOfView = 60; break; case 5: orbitScript.enabled = false; carCamera.enabled = false; carCamera.transform.parent = null; break; } }
public void ChangeCamera() { target = carCamera.playerCar; if(!target) return; cameraChangeCount++; if(cameraChangeCount >= 5) cameraChangeCount = 0; if(target.GetComponent<RCCCarCameraConfig>()){ dist = target.GetComponent<RCCCarCameraConfig>().distance; height = target.GetComponent<RCCCarCameraConfig>().height; carCamera.distance = dist; carCamera.height = height; } if(useOrbitCamera){ orbitScript.target = target.transform; orbitScript.distance = dist; } if(target.GetComponentInChildren<RCCCockpitCamera>()) cockpitCamera = target.GetComponentInChildren<RCCCockpitCamera>(); if(target.GetComponentInChildren<RCCWheelCamera>()) wheelCamera = target.GetComponentInChildren<RCCWheelCamera>(); switch(cameraChangeCount){ case 0: if(useFixedCamera){ if(GameObject.FindObjectOfType<RCCMainFixedCam>()) GameObject.FindObjectOfType<RCCMainFixedCam>().canTrackNow = false; } carCamera.enabled = true; orbitScript.enabled = false; carCamera.transform.SetParent(null); break; case 1: if(!useOrbitCamera){ ChangeCamera(); break; } orbitScript.enabled = true; carCamera.enabled = false; carCamera.transform.SetParent(null); break; case 2: if(!cockpitCamera){ ChangeCamera(); break; } orbitScript.enabled = false; carCamera.enabled = false; carCamera.transform.SetParent(cockpitCamera.transform); carCamera.transform.localPosition = Vector3.zero; carCamera.transform.localRotation = Quaternion.identity; carCamera.GetComponent<Camera>().fieldOfView = 60; break; case 3: if(!wheelCamera){ ChangeCamera(); break; } orbitScript.enabled = false; carCamera.enabled = false; carCamera.transform.SetParent(wheelCamera.transform); carCamera.transform.localPosition = Vector3.zero; carCamera.transform.localRotation = Quaternion.identity; carCamera.GetComponent<Camera>().fieldOfView = 60; break; case 4: if(!useFixedCamera){ ChangeCamera(); break; } orbitScript.enabled = false; carCamera.enabled = false; carCamera.transform.SetParent(null); GameObject.FindObjectOfType<RCCMainFixedCam>().mainCamera = GetComponent<Camera>(); GameObject.FindObjectOfType<RCCMainFixedCam>().player = target; GameObject.FindObjectOfType<RCCMainFixedCam>().canTrackNow = true; break; } }
public void ChangeCamera() { if(!target) return; cameraChangeCount++; if(cameraChangeCount >= 5) cameraChangeCount = 0; if(target.GetComponent<RCCCarCameraConfig>()){ dist = target.GetComponent<RCCCarCameraConfig>().distance; height = target.GetComponent<RCCCarCameraConfig>().height; carCamera.distance = dist; carCamera.height = height; } if(useOrbitCamera){ orbitScript.target = target.transform; orbitScript.distance = dist; } if(target.GetComponentInChildren<RCCCockpitCamera>()) cockpitCamera = target.GetComponentInChildren<RCCCockpitCamera>(); if(target.GetComponentInChildren<RCCWheelCamera>()) wheelCamera = target.GetComponentInChildren<RCCWheelCamera>(); switch(cameraChangeCount){ case 0: orbitScript.enabled = false; carCamera.enabled = true; carCamera.transform.parent = null; break; case 1: if(!useOrbitCamera){ ChangeCamera(); break; } orbitScript.enabled = true; carCamera.enabled = false; carCamera.transform.parent = null; break; case 2: if(!useFixedCamera){ ChangeCamera(); break; } orbitScript.enabled = false; carCamera.enabled = false; carCamera.transform.parent = null; break; case 3: orbitScript.enabled = false; carCamera.enabled = false; carCamera.transform.parent = target; if(!cockpitCamera){ ChangeCamera(); break; } carCamera.transform.localPosition = cockpitCamera.transform.localPosition; carCamera.transform.localRotation = cockpitCamera.transform.localRotation; carCamera.GetComponent<Camera>().fieldOfView = 60; break; case 4: orbitScript.enabled = false; carCamera.enabled = false; carCamera.transform.parent = target; if(!wheelCamera){ ChangeCamera(); break; } carCamera.transform.localPosition = wheelCamera.transform.localPosition; carCamera.transform.localRotation = wheelCamera.transform.localRotation; carCamera.GetComponent<Camera>().fieldOfView = 60; break; case 5: orbitScript.enabled = false; carCamera.enabled = false; carCamera.transform.parent = null; break; } }
public void ChangeCamera() { target = carCamera.playerCar; if (!target) { return; } cameraChangeCount++; if (cameraChangeCount >= 5) { cameraChangeCount = 0; } if (target.GetComponent <RCCCarCameraConfig>()) { dist = target.GetComponent <RCCCarCameraConfig>().distance; height = target.GetComponent <RCCCarCameraConfig>().height; carCamera.distance = dist; carCamera.height = height; } if (useOrbitCamera) { orbitScript.target = target.transform; orbitScript.distance = dist; } if (target.GetComponentInChildren <RCCCockpitCamera>()) { cockpitCamera = target.GetComponentInChildren <RCCCockpitCamera>(); } if (target.GetComponentInChildren <RCCWheelCamera>()) { wheelCamera = target.GetComponentInChildren <RCCWheelCamera>(); } switch (cameraChangeCount) { case 0: if (useFixedCamera) { if (GameObject.FindObjectOfType <RCCMainFixedCam>()) { GameObject.FindObjectOfType <RCCMainFixedCam>().canTrackNow = false; } } carCamera.enabled = true; orbitScript.enabled = false; carCamera.transform.SetParent(null); break; case 1: if (!useOrbitCamera) { ChangeCamera(); break; } orbitScript.enabled = true; carCamera.enabled = false; carCamera.transform.SetParent(null); break; case 2: if (!cockpitCamera) { ChangeCamera(); break; } orbitScript.enabled = false; carCamera.enabled = false; carCamera.transform.SetParent(cockpitCamera.transform); carCamera.transform.localPosition = Vector3.zero; carCamera.transform.localRotation = Quaternion.identity; carCamera.GetComponent <Camera>().fieldOfView = 60; break; case 3: if (!wheelCamera) { ChangeCamera(); break; } orbitScript.enabled = false; carCamera.enabled = false; carCamera.transform.SetParent(wheelCamera.transform); carCamera.transform.localPosition = Vector3.zero; carCamera.transform.localRotation = Quaternion.identity; carCamera.GetComponent <Camera>().fieldOfView = 60; break; case 4: if (!useFixedCamera) { ChangeCamera(); break; } orbitScript.enabled = false; carCamera.enabled = false; carCamera.transform.SetParent(null); GameObject.FindObjectOfType <RCCMainFixedCam>().mainCamera = GetComponent <Camera>(); GameObject.FindObjectOfType <RCCMainFixedCam>().player = target; GameObject.FindObjectOfType <RCCMainFixedCam>().canTrackNow = true; break; } }