public void changeBoundingVolume() { confiner.InvalidatePathCache(); if (confiner.m_BoundingShape2D == upperConstraint) { confiner.m_BoundingShape2D = lowerConstraint; } else if (confiner.m_BoundingShape2D == lowerConstraint) { confiner.m_BoundingShape2D = upperConstraint; } }
/// <summary> /// Resizes the confiner /// </summary> /// <returns></returns> protected virtual IEnumerator ResizeConfiner() { if ((VirtualCamera == null) || (Confiner == null) || !ResizeConfinerAutomatically) { yield break; } // we wait two more frame for Unity's pixel perfect camera component to be ready because apparently sending events is not a thing. yield return(null); yield return(null); (Confiner as BoxCollider2D).offset = _roomCollider2D.offset; (Confiner as BoxCollider2D).size = (_roomCollider2D as BoxCollider2D).size; _cameraSize.y = 2 * _mainCamera.orthographicSize; _cameraSize.x = _cameraSize.y * _mainCamera.aspect; Vector2 newSize = (Confiner as BoxCollider2D).size; if ((Confiner as BoxCollider2D).size.x < _cameraSize.x) { newSize.x = _cameraSize.x; } if ((Confiner as BoxCollider2D).size.y < _cameraSize.y) { newSize.y = _cameraSize.y; } (Confiner as BoxCollider2D).size = newSize; CinemachineCameraConfiner.InvalidatePathCache(); HandleLevelStartDetection(); }
public void SwapVCam(Collider2D newBound) { subvcam.SetActive(true); m_SubCinemachineConfiner.m_BoundingShape2D = newBound; m_SubCinemachineConfiner.InvalidatePathCache(); m_CellChanging = true; }
/// <summary> /// Switchs the collider for the cinemachine camera /// </summary> private void SwitchBoundingShape() { PolygonCollider2D col = GameObject.FindGameObjectWithTag(Tags.BoundsConfiner).GetComponent <PolygonCollider2D>(); CinemachineConfiner confiner = GetComponent <CinemachineConfiner>(); confiner.m_BoundingShape2D = col; confiner.InvalidatePathCache(); }
void FindConfiner() { confiner = cmVcam.GetComponent <CinemachineConfiner>(); if (confiner != null) { confiner.InvalidatePathCache(); confiner.m_BoundingShape2D = GameObject.FindGameObjectWithTag("Bound").GetComponent <Collider2D>(); } }
private void SetVirtualCameraConfiner() { CinemachineConfiner cinemachineConfiner = virtualCamera.gameObject.GetComponent <CinemachineConfiner>(); if (cinemachineConfiner != null) { cinemachineConfiner.m_BoundingShape2D = levelSettings.VirtualCameraConfiner; cinemachineConfiner.InvalidatePathCache(); } }
/// <summary> /// Switches the confiner that the cinemachine uses to define screen shape. /// </summary> private void SwitchBoundingShape() { //Get polygon collider used by cinemachine PolygonCollider2D polygonCollider2D = GameObject.FindGameObjectWithTag(Tags.BoundConfiner).GetComponent <PolygonCollider2D>(); CinemachineConfiner cinemachineConfiner = GetComponent <CinemachineConfiner>(); cinemachineConfiner.m_BoundingShape2D = polygonCollider2D; //Special function to clear cache cinemachineConfiner.InvalidatePathCache(); }
private void UnlockSecretArea() { _disabledColliders .ForEach(coll => { coll.enabled = true; coll.usedByComposite = true; }); _confiner.InvalidatePathCache(); StartCoroutine(SecretAreaDamping()); }
void SetCinemachineConfines() { // Set camera bounds to the one in the level, if any. PolygonCollider2D cameraBounds = GameObject.FindWithTag("CameraBoundingBox").GetComponent <PolygonCollider2D>(); CinemachineConfiner confiner = FindObjectOfType <CinemachineConfiner>(); confiner.m_BoundingShape2D = cameraBounds; // Cinemachine doesn't automatically update performance path. // This makes sure the path is updated. confiner.InvalidatePathCache(); }
public void SetConfinerBoundingShape(Collider2D collider) { cinemachineConfiner.InvalidatePathCache(); StartCoroutine(TriggerConfinerDamping()); if (currentCollider != null) { previousCollider = currentCollider; } currentCollider = collider; cinemachineConfiner.m_BoundingShape2D = currentCollider; }
/// <summary> /// Switch the collider that cinemachine uses to define teh edges of the screen ///</summary> private void SwitchBoundingShape() { // Get the polygon collider on the 'boundsconfiner' gameobject which is used by cinemachine to prevent teh camera going beyong the screen edges PolygonCollider2D polygonCollider2D = GameObject.FindGameObjectWithTag(Tags.BoundsConfiner).GetComponent <PolygonCollider2D>(); CinemachineConfiner cinemachineConfiner = GetComponent <CinemachineConfiner>(); cinemachineConfiner.m_BoundingShape2D = polygonCollider2D; // since teh confiner bounds have changed need to call this to clear the cache. cinemachineConfiner.InvalidatePathCache(); }
void LateUpdate() { if (!m_CellChanging) { return; } if (m_ActivationFrameCount < m_DelayFrameCount) { m_ActivationFrameCount += 1; return; } if (!m_MainCinemachineBrain.IsBlending) { m_MainCinemachineConfiner.m_BoundingShape2D = m_SubCinemachineConfiner.m_BoundingShape2D; m_MainCinemachineConfiner.InvalidatePathCache(); subvcam.SetActive(false); OnDisabledPreviousCell.Invoke(); m_ActivationFrameCount = 0; m_CellChanging = false; } }
/// <summary> /// Switch in the collider that cinemachine uses to define the edges of the screen. /// This is called whenever a new scene is fully loaded. /// Here we find the gameObject with the correct tag, to get the bounds confiner polygon collider /// We do this here instead of in Start() because the scene load coroutine is additive and this will not be able to find it until the scene is fully loaded /// </summary> private void SwitchBoundingShape() { // Get the polygon collider on the 'BoundsConfiner' gameObject (in the Scene1_farm scene) which is used // by Cinemachine (in the PersistentScene) to prevent the camera from going beyond the screen edges PolygonCollider2D polygoncollider2D = GameObject.FindGameObjectWithTag(Tags.BoundsConfiner).GetComponent <PolygonCollider2D>(); CinemachineConfiner cinemachineConfiner = GetComponent <CinemachineConfiner>(); cinemachineConfiner.m_BoundingShape2D = polygoncollider2D; // Since the confiner bounds have been changed, call this to clear the cache cinemachineConfiner.InvalidatePathCache(); }
//Changes the collider that Cinemachine uses to determine the edges of the screen private void SwitchBoundingShape() { //Get the polygon collider on the bounds confiner PolygonCollider2D polygonCollider2D = GameObject.FindGameObjectWithTag(Tags.BoundsConfiner).GetComponent <PolygonCollider2D>(); //Get the cinemachine confiner CinemachineConfiner cinemachineConfiner = GetComponent <CinemachineConfiner>(); //Set the cinemachine confiner's m_BoundingShape2D property to the polygon collider on the bounds confiner cinemachineConfiner.m_BoundingShape2D = polygonCollider2D; //Clear the cache & reapply the polygon collider cinemachineConfiner.InvalidatePathCache(); }
/// <summary> /// Resizes the confiner /// </summary> /// <returns></returns> protected virtual IEnumerator ResizeConfiner() { if ((VirtualCamera == null) || (Confiner == null) || !ResizeConfinerAutomatically) { yield break; } // we wait two more frame for Unity's pixel perfect camera component to be ready because apparently sending events is not a thing. yield return(null); yield return(null); Confiner.transform.position = RoomColliderCenter; Vector3 size = RoomColliderSize; switch (Mode) { case Modes.TwoD: size.z = RoomDepth; Confiner.size = size; _cameraSize.y = 2 * _mainCamera.orthographicSize; _cameraSize.x = _cameraSize.y * _mainCamera.aspect; Vector3 newSize = Confiner.size; if (Confiner.size.x < _cameraSize.x) { newSize.x = _cameraSize.x; } if (Confiner.size.y < _cameraSize.y) { newSize.y = _cameraSize.y; } Confiner.size = newSize; break; case Modes.ThreeD: Confiner.size = size; break; } CinemachineCameraConfiner.InvalidatePathCache(); //HandleLevelStartDetection(); }
void Update() { if (player.transform.position.x > activeGround.transform.position.x + groundChunkSize + slightBuffer) { ClearGroundOfVillagers(previousGround); var temp = previousGround; previousGround = activeGround; activeGround = nextGround; var position = temp.transform.position; position.x = activeGround.transform.position.x + groundChunkSize; temp.transform.position = position; nextGround = temp; } else if (player.transform.position.x < activeGround.transform.position.x - slightBuffer) { ClearGroundOfVillagers(nextGround); var temp = nextGround; nextGround = activeGround; activeGround = previousGround; var position = temp.transform.position; position.x = activeGround.transform.position.x - groundChunkSize; temp.transform.position = position; previousGround = temp; } else { return; } var updatedBounds = new Vector2[4]; updatedBounds[0] = new Vector2(previousGround.transform.position.x, previousGround.transform.position.y); updatedBounds[1] = new Vector2(previousGround.transform.position.x, previousGround.transform.position.y + groundChunkSize); updatedBounds[2] = new Vector2(nextGround.transform.position.x + groundChunkSize, nextGround.transform.position.y + groundChunkSize); updatedBounds[3] = new Vector2(nextGround.transform.position.x + groundChunkSize, nextGround.transform.position.y); levelBoundsPolygonCollider.points = updatedBounds; confiner.InvalidatePathCache(); }
public void CameraConfinerKudeatu(Vector2 pos) { for (int i = 0; i < bounds.Length; i++) { if (bounds[i].bounds.Contains(pos)) { confiner.m_BoundingShape2D = bounds[i]; confiner.InvalidatePathCache(); aldaketak = true; cam.GetCinemachineComponent <CinemachineFramingTransposer>().m_LookaheadTime = 0; cam.GetCinemachineComponent <CinemachineFramingTransposer>().m_DeadZoneWidth = 0; cam.GetCinemachineComponent <CinemachineFramingTransposer>().m_DeadZoneHeight = 0; cam.GetCinemachineComponent <CinemachineFramingTransposer>().m_XDamping = 0; cam.GetCinemachineComponent <CinemachineFramingTransposer>().m_YDamping = 0; StartCoroutine(Itxaron()); break; } } }
// Update is called once per frame void Update() { if (currentPlayer != null) { cam.Follow = currentPlayer.transform; } if (Input.GetKeyDown(KeyCode.Q)) { currentPlayer = Instantiate(players[1], this.gameObject.transform.position, Quaternion.identity); } if (Input.GetKeyDown(KeyCode.E)) { currentPlayer = Instantiate(players[0], this.gameObject.transform.position, Quaternion.identity); } if (aCameraConfiner.m_BoundingShape2D == null) { //Update Camera Confiner aCameraConfiner.InvalidatePathCache(); aCameraConfiner.m_BoundingShape2D = GameObject.FindGameObjectWithTag("Confiner").GetComponent <Collider2D>(); } }
private void Start() { Collider2D collider2D = GetComponent <Collider2D>(); if (!collider2D) { Debug.LogWarning($"{gameObject.name}: {GetType()}: Requires an Collider2D component."); return; } Scene scene = SceneManager.GetSceneByName(cameraScene); if (scene.IsValid()) { bool foundConfiner = false; GameObject[] rootObjects = scene.GetRootGameObjects(); foreach (GameObject root in rootObjects) { CinemachineConfiner confiner = root.GetComponentInChildren <CinemachineConfiner>(true); if (confiner) { confiner.m_BoundingShape2D = collider2D; confiner.InvalidatePathCache(); foundConfiner = true; } } if (!foundConfiner) { Debug.LogWarning($"{gameObject.name}: {GetType()}: Couldn't find confiner in scene {cameraScene}"); } } else { Debug.LogWarning($"{gameObject.name}: {GetType()}: Couldn't find scene with name {cameraScene}"); } }
public void ChangeConfiner(int index) { confiner.InvalidatePathCache(); confiner.m_BoundingShape2D = boundingBoxes[index]; }
public void SetAllGroundCollider() { _cinemachineConfiner.m_BoundingShape2D = allGroundCollider; _cinemachineConfiner.InvalidatePathCache(); }
public void EnableConfines(Collider2D newBounds) { _confiner.m_BoundingShape2D = newBounds; _confiner.InvalidatePathCache(); _confiner.enabled = true; }
/// <summary> /// Update confiner on the virtual camera /// </summary> /// <param name="collider"></param> public void UpdateConfiner(PolygonCollider2D collider) { confiner.m_BoundingShape2D = collider; confiner.InvalidatePathCache(); }
void UpdateCameraBounds(Collider2D newBounds) { cameraConfiner.m_BoundingShape2D = newBounds; cameraConfiner.InvalidatePathCache(); }
public void SetConfinerColider(Collider2D colider) { confiner.m_BoundingShape2D = colider; confiner.InvalidatePathCache(); }