aboutsummaryrefslogtreecommitdiff
path: root/Assets/Scripts/PlayerPosition.cs
diff options
context:
space:
mode:
authorWeicao-CatilGrass <1992414357@qq.com>2026-05-30 19:35:16 +0800
committerWeicao-CatilGrass <1992414357@qq.com>2026-05-30 19:35:16 +0800
commit7735b716401f630697d5b02910d50dbf8f3416af (patch)
tree52d23e7e0434a569bbafdfca6ad196e3ef24af3f /Assets/Scripts/PlayerPosition.cs
parent4408cc53e044a9c649572991a764f46d247c67bf (diff)
正在编写动态场景加载
Diffstat (limited to 'Assets/Scripts/PlayerPosition.cs')
-rw-r--r--Assets/Scripts/PlayerPosition.cs30
1 files changed, 30 insertions, 0 deletions
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<PlayerLocomotion>();
+ yield return new WaitForSeconds(5f);
+ }
+ }
+}