blob: baf4e66b3610146851b7f92673a618b32ead14ef (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
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<PlayerLocomotion>();
if (list.Length > 0)
_playerLocomotion = list[0];
yield return new WaitForSeconds(5f);
}
}
}
|