/// <summary> /// 摄像机震动 /// </summary> /// <param name="shakeStrength">震动幅度</param> /// <param name="rate">震动频率</param> /// <param name="shakeTime">震动时长</param> /// <returns></returns> IEnumerator ShakeCamera(float shakeStrength = 0.2f, float rate = 14, float shakeTime = 0.3f) { // StopCamSmoothFollow(); float t = 0; float speed = 1 / shakeTime; foreach (Camera oneCamera in m_Cameras) { Vector3 m_DefaultPos = oneCamera.transform.position; while (t < 1) { t += Time.deltaTime * speed; oneCamera.transform.position = m_DefaultPos + new Vector3(Mathf.Sin(rate * t), Mathf.Cos(rate * t), 0) * Mathf.Lerp(shakeStrength, 0, t); yield return(null); } oneCamera.transform.position = m_DefaultPos; } m_CurType = CamEftType.NULL; }
// shake public void Shake(float shakeStrength = 0.1f, float rate = 14, float shakeTime = 0.3f) { if (m_CurType == CamEftType.LookAt) { return; } m_CurType = CamEftType.Shake; StartCoroutine(ShakeCamera(shakeStrength, rate, shakeTime)); }
void Start() { m_Pos2Hero = new Vector3(0, 0, -10f * dis); m_CurType = CamEftType.NULL; // SetFollowTar(Global.instance.m_Player.transform.position); m_SunDefaultIntensity = m_SunLight.intensity; // auto loop flash // StartCoroutine(IE_LoopFlash()); // set follow target this.SetFollowTar(Global.instance.m_Hero_01.transform); }
public void DoLookAt_MoveBy(Vector3 deltPos) { m_CurType = CamEftType.LookAt; }