public IEnumerator <WaitCommand> AnimateToMount(ICameraMount mount, TimeSpan duration) { if (_transitionActive) { Debug.LogError("Attempting to transition between mounts while another transition is still active"); yield break; } _transitionActive = true; yield return(Routines.Animate(_clock.PollDeltaTime, duration, lerp => { _rig.transform.position = Vector3.Lerp(_mount.transform.position, mount.transform.position, lerp); _rig.transform.rotation = Quaternion.Slerp(_mount.transform.rotation, mount.transform.rotation, lerp); }).AsWaitCommand()); if (_mount != null) { _mount.OnDismount(Rig); } _mount = mount; if (_mount != null) { _mount.OnMount(Rig); } _transitionActive = false; }
public void SwitchMount(ICameraMount mount) { if (_transitionActive) { Debug.LogError("Attempting to transition between mounts while another transition is still active"); return; } if (mount == null) { throw new ArgumentException("Mount cannot be null"); } if (_mount != null) { _mount.OnDismount(Rig); } _mount = mount; if (_mount != null) { _mount.OnMount(Rig); } // Timeless transition implies teleportation, so inform the mounts _rig.Teleport(); }
public SpectatorMode(IStateMachine machine, Data data) : base(machine) { _data = data; _spectatorCameraMount = _data.SpectatorCamera.GetComponent <ICameraMount>(); }