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); var list = Resources.FindObjectsOfTypeAll(); if (list.Length > 0) _playerLocomotion = list[0]; yield return new WaitForSeconds(5f); } } }