public void StartCloseup(ICloseupable currentCloseupable) { Debug.Log("start closeup"); offsetToTheLeftToMakeSpaceForInspectionText = currentCloseupable.ShouldOffset(); Game.SoundPlayer.Play(startCloseupSound, randomPitchRange: 0.15f); Game.MouseInteractor.ForceEndHover(); currentCloseupable.OnStartCloseup(); originalPosition = currentCloseupable.GetPosition(); originalRotation = currentCloseupable.GetRotation(); }
private void UpdatePositionAndRotation(ICloseupable closeupable, Vector3 tPos, Quaternion tRot, bool lerp = false) { if (lerp) { Vector3 pos = Vector3.MoveTowards(closeupable.GetPosition(), tPos, Time.deltaTime * 100); Quaternion rot = Quaternion.Euler(Vector3.MoveTowards(closeupable.GetRotation().eulerAngles, tRot.eulerAngles, Time.deltaTime * 100)); closeupable.UpdatePositionAndRotation(pos, rot); } else { closeupable.UpdatePositionAndRotation(tPos, tRot); } }
IEnumerator PanBackRoutine(ICloseupable closeupable) { Vector3 tPos = originalPosition; Quaternion tRot = originalRotation; while (Vector3.Distance(tPos, closeupable.GetPosition()) > 0.01f) { yield return(null); UpdatePositionAndRotation(closeupable, tPos, tRot, lerp: true); } closeupable.UpdatePositionAndRotation(tPos, tRot); closeupable.OnEndCloseup(); }
public void UpdateCloseup(ICloseupable currentCloseupable) { targetPosition = closeupTransform.position - (offsetToTheLeftToMakeSpaceForInspectionText?closeupTransform.right:Vector3.zero); if (Input.GetMouseButton(0)) { var x = mousePositionBefore.x - Input.mousePosition.x; var y = Input.mousePosition.y - mousePositionBefore.y; targetRotation = Quaternion.Euler(-x / 2, x / 2, y) * currentCloseupable.GetRotation(); } mousePositionBefore = Input.mousePosition; UpdatePositionAndRotation(currentCloseupable, targetPosition, targetRotation, Vector3.Distance(targetPosition, currentCloseupable.GetPosition()) > 0.01f); }