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); } } }