void SwitchCamera(Transform t) { if (onLock && t) { if (t != player) { lockIcon.gameObject.SetActive(true); PositionConstraint pc = lockIcon.GetComponent <PositionConstraint>(); if (pc) { if (pc.sourceCount > 0) { pc.RemoveSource(0); } constraintSource.sourceTransform = t; constraintSource.weight = 1; pc.AddSource(constraintSource); //pc.translationOffset = Vector3.zero; //pc.translationAtRest = Vector3.zero; } lockVcam.GetComponent <CinemachineVirtualCamera>().LookAt = t; lockVcam.GetComponent <CinemachineVirtualCamera>().Priority = mainPriority + 1; return; } } lockIcon.gameObject.SetActive(false); lockVcam.GetComponent <CinemachineVirtualCamera>().Priority = mainPriority - 1; }
//Pos Constrait------------------------------------------------------------- //Clear Sourcers public static void ClearSources(this PositionConstraint posCons) { int length = posCons.sourceCount; for (int i = 0; i < length; i++) { posCons.RemoveSource(0); } }
private static void RemoveRigTarget() { Smart3DOFTarget b = Selection.activeGameObject.GetComponent <Smart3DOFTarget>(); Transform cam = b.reference; PositionConstraint constraint = cam.GetComponent <PositionConstraint>(); constraint.RemoveSource(b.index); DestroyImmediate(b.gameObject); }
private void SetCameraConstraint(SimplePhysicsMovement coreInstance) { var sourceCount = _cameraConstraint.sourceCount; for (int i = 0; i < sourceCount; i++) { _cameraConstraint.RemoveSource(0); } ConstraintSource coreSource = new ConstraintSource(); coreSource.sourceTransform = coreInstance.transform; coreSource.weight = 1; _cameraConstraint.AddSource(coreSource); }
protected override bool Open(T unit) { var result = base.Open(unit); if (result) { transform.position = mainCamera.WorldToScreenPoint(unit.transform.position + WorldOffset) .SetZ(transform.parent != null ? transform.parent.position.z : 0) + ScreenOffset; if (constraint) { while (constraint.sourceCount > 0) { constraint.RemoveSource(0); } constraint.translationOffset = WorldOffset; constraint.AddSource(new ConstraintSource { sourceTransform = unit.transform, weight = 1 }); constraint.enabled = true; } if (follower) { follower.offset = WorldOffset; follower.screenOffset = ScreenOffset; follower.target = unit.transform; follower.enabled = true; } } return(result); }