private void Update() { #if UNITY_EDITOR // SKIP if (Input.GetKeyDown(KeyCode.F1) && !m_qte_shack) { StopCoroutine("on_qte_end"); to_gameplay(); } if (Input.GetKeyDown(KeyCode.F2) && !m_qte_shack) { m_director.Stop(); StopCoroutine("on_qte_end"); QTEManager.Instance.play_qte(m_start_qte); m_qte_shack = true; GameEvent <QTEEndEvent> .Register(on_qte_end); m_shake_instance = new CameraShakeInstance(m_shake_curve_mag.Evaluate(0f), m_shake_curve_rough.Evaluate(0f)); m_shake_instance.StartFadeIn(0.1f); } #endif if (m_qte_shack) { m_shake_instance.Magnitude = m_shake_curve_mag.Evaluate(QTEManager.Instance.m_mash_amount); m_shake_instance.Roughness = m_shake_curve_rough.Evaluate(QTEManager.Instance.m_mash_amount); Vector3 pos = m_shake_instance.UpdateShake(); m_camera_shake.GetCinemachineComponent <CinemachineTrackedDolly>().m_PathOffset = pos; m_hamster.speed = m_cage.speed = m_animation_speed.Evaluate(QTEManager.Instance.m_mash_amount); } }
private void OnTriggerEnter(Collider c) { if (c.CompareTag("Player")) { _shakeInstance.StartFadeIn(1f); } }
//When the player enters the trigger, begin shaking. void OnTriggerEnter(Collider c) { //Check to make sure the object that entered the trigger was the player. if (c.CompareTag("Player")) { _shakeInstance.StartFadeIn(1); } }
//When the player enters the trigger, begin shaking. private void OnTriggerEnter2D(Collider2D c) { //Check to make sure the object that entered the trigger was the player. if (c.CompareTag("Player")) { shake.StartFadeIn(0); } }
/// <summary> /// Start shaking the camera. /// </summary> /// <param name="magnitude">The intensity of the shake.</param> /// <param name="roughness">Roughness of the shake. Lower values are smoother, higher values are more jarring.</param> /// <param name="fadeInTime">How long to fade in the shake, in seconds.</param> /// <param name="posInfluence">How much this shake influences position.</param> /// <param name="rotInfluence">How much this shake influences rotation.</param> /// <returns>A CameraShakeInstance that can be used to alter the shake's properties.</returns> public CameraShakeInstance StartShake(float magnitude, float roughness, float fadeInTime, Vector3 posInfluence, Vector3 rotInfluence) { CameraShakeInstance shake = new CameraShakeInstance(magnitude, roughness); shake.PositionInfluence = posInfluence; shake.RotationInfluence = rotInfluence; shake.StartFadeIn(fadeInTime); cameraShakeInstances.Add(shake); return(shake); }
public void CameraStartShake(bool fadeIn) { if (fadeIn) { shakeInstance.StartFadeIn(1f); } else { shakeInstance.StartFadeOut(3f); } }
private CameraShakeInstance ShakeSetup(CameraShakeInstance instance, float mag, float rough, float timeIn) { if (instance == null) //First time shake setup { instance = CameraShaker.Instance.StartShake(mag, rough, timeIn); // Create shake } else { instance.StartFadeIn(timeIn); //Start shaker instance shaking } return(instance); }
IEnumerator PlaySong(BeatScroller scroller) { playing = true; audioSource.Stop(); dialogueText.SetActive(false); scroller.hasStarted = true; yield return(new WaitForSeconds(0.97f)); shake.StartFadeIn(0); audioSource.clip = song; audioSource.Play(); audioSource.loop = false; yield return(new WaitForSeconds(song.length)); finishedSong = true; }
private IEnumerator play_into_cinematic() { m_director.Play(); yield return(new WaitForSecondsRealtime((float)m_director.duration)); NarrativeAudioManager.Get().PlayLine(m_IntroMainLine); yield return(new WaitForSecondsRealtime(0.5f)); yield return(new WaitUntil(() => !NarrativeAudioManager.Get().IsPlaying())); QTEManager.Instance.play_qte(m_start_qte); m_qte_shack = true; GameEvent <QTEEndEvent> .Register(on_qte_end); m_shake_instance = new CameraShakeInstance(m_shake_curve_mag.Evaluate(0f), m_shake_curve_rough.Evaluate(0f)); m_shake_instance.StartFadeIn(0.1f); NarrativeAudioManager.Get().PlayLine(m_IntroEscapeLine); }
void OnGUI() { if (Input.GetKeyDown(KeyCode.R)) { // Application.LoadLevel(Application.loadedLevel); SceneManager.LoadScene(SceneManager.GetActiveScene().name); } Slider s = delegate(float val, string prefix, float min, float max, int pad) { GUILayout.BeginHorizontal(); GUILayout.Label(prefix, GUILayout.MaxWidth(pad)); val = GUILayout.HorizontalSlider(val, min, max); GUILayout.Label(val.ToString("F2"), GUILayout.MaxWidth(50)); GUILayout.EndHorizontal(); return(val); }; GUI.Box(new Rect(10, 10, 250, Screen.height - 15), "Make-A-Shake"); GUILayout.BeginArea(new Rect(29f, 40, 215, Screen.height - 40)); GUILayout.Label("--Position Infleunce--"); posInf.x = s(posInf.x, "X", 0, 4, 25); posInf.y = s(posInf.y, "Y", 0, 4, 25); posInf.z = s(posInf.z, "Z", 0, 4, 25); GUILayout.Label("--Rotation Infleunce--"); rotInf.x = s(rotInf.x, "X", 0, 4, 25); rotInf.y = s(rotInf.y, "Y", 0, 4, 25); rotInf.z = s(rotInf.z, "Z", 0, 4, 25); GUILayout.Label("--Other Properties--"); magn = s(magn, "Magnitude:", 0, 10, 75); rough = s(rough, "Roughness:", 0, 20, 75); fadeIn = s(fadeIn, "Fade In:", 0, 10, 75); fadeOut = s(fadeOut, "Fade Out:", 0, 10, 75); GUILayout.Label("--Saved Shake Instance--"); GUILayout.Label("You can save shake instances and modify their properties at runtime."); if (shake == null && GUILayout.Button("Create Shake Instance")) { shake = CameraShaker.Instance.StartShake(magn, rough, fadeIn); shake.DeleteOnInactive = false; } if (shake != null) { if (GUILayout.Button("Delete Shake Instance")) { shake.DeleteOnInactive = true; shake.StartFadeOut(fadeOut); shake = null; } if (shake != null) { GUILayout.BeginHorizontal(); if (GUILayout.Button("Fade Out")) { shake.StartFadeOut(fadeOut); } if (GUILayout.Button("Fade In")) { shake.StartFadeIn(fadeIn); } GUILayout.EndHorizontal(); modValues = GUILayout.Toggle(modValues, "Modify Instance Values"); if (modValues) { shake.ScaleMagnitude = magn; shake.ScaleRoughness = rough; shake.PositionInfluence = posInf; shake.RotationInfluence = rotInf; } } } GUILayout.Label("--Shake Once--"); GUILayout.Label("You can simply have a shake that automatically starts and stops too."); if (GUILayout.Button("Shake!")) { CameraShakeInstance c = CameraShaker.Instance.ShakeOnce(magn, rough, fadeIn, fadeOut); c.PositionInfluence = posInf; c.RotationInfluence = rotInf; } GUILayout.EndArea(); float height; if (!showList) { height = 120; } else { height = 120 + CameraShaker.Instance.ShakeInstances.Count * 130f; } GUI.Box(new Rect(Screen.width - 310, 10, 300, height), "Shake Instance List"); GUILayout.BeginArea(new Rect(Screen.width - 285, 40, 255, Screen.height - 40)); GUILayout.Label("All shake instances are saved and stacked as long as they are active."); showList = GUILayout.Toggle(showList, "Show List"); if (showList) { int index = 1; foreach (CameraShakeInstance c in CameraShaker.Instance.ShakeInstances) { string state = c.CurrentState.ToString(); GUILayout.Label("#" + index + ": Magnitude: " + c.Magnitude.ToString("F2") + ", Roughness: " + c.Roughness.ToString("F2")); GUILayout.Label(" Position Influence: " + c.PositionInfluence); GUILayout.Label(" Rotation Influence: " + c.RotationInfluence); GUILayout.Label(" State: " + state); GUILayout.Label("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"); index++; } } GUILayout.EndArea(); }
public static void ShakeAfterShieldHit() { _shakeShieldInstance.StartFadeIn(0); _shakeShieldInstance.StartFadeOut(.5f); }
public static void ShakeAfterDeath() { _shakePlayerInstance.StartFadeIn(0); _shakePlayerInstance.StartFadeOut(1); }