From 7735b716401f630697d5b02910d50dbf8f3416af Mon Sep 17 00:00:00 2001 From: Weicao-CatilGrass <1992414357@qq.com> Date: Sat, 30 May 2026 19:35:16 +0800 Subject: 正在编写动态场景加载 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/PlayerPosition.cs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Assets/Scripts/PlayerPosition.cs (limited to 'Assets/Scripts/PlayerPosition.cs') diff --git a/Assets/Scripts/PlayerPosition.cs b/Assets/Scripts/PlayerPosition.cs new file mode 100644 index 0000000..9b839f8 --- /dev/null +++ b/Assets/Scripts/PlayerPosition.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections; +using DS; +using UnityEngine; + +public class PlayerPosition : MonoBehaviour +{ + private PlayerLocomotion _playerLocomotion; + + private void Awake() + { + StartCoroutine(FindPlayer()); + } + + private void Update() + { + if (_playerLocomotion != null) + transform.position = _playerLocomotion.transform.position; + } + + IEnumerator FindPlayer() + { + while (true) + { + yield return new WaitUntil(() => _playerLocomotion == null); + _playerLocomotion = GetComponent(); + yield return new WaitForSeconds(5f); + } + } +} -- cgit