diff options
Diffstat (limited to 'Assets/Scripts/PlayerPosition.cs')
| -rw-r--r-- | Assets/Scripts/PlayerPosition.cs | 30 |
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); + } + } +} |
