using System.Collections; using System.Collections.Generic; using UnityEngine; using BigSpace.Logic; using BigSpace.XRCore.Event; using UnityEngine.Playables; using BigSpace.XRCore.Base; public class CameraShake : MonoSingleton { bool isShake = false; //¼ÆÊ±Ïà¹Ø float waitTime = 10f; float runTime = 0; Vector3 StarPositon; // Start is called before the first frame update void Start() { GlobalEventMgr.Listen(GameEvent.EventCameraShake, GameDataManage_EventCameraShake); StarPositon = this.transform.localPosition; } void GameDataManage_EventCameraShake() { isShake = true; } private void Update() { if (isShake) { Vector3 shake = new Vector3(Random.Range(-0.5f, 0.5f), Random.Range(-1.0f, 1.0f), 0); transform.localPosition += shake * Time.deltaTime; runTime += Time.deltaTime; if (runTime >= waitTime) { isShake = false; runTime = 0; transform.localPosition = StarPositon; } } } }