blob: 9b839f81b972cb9b5338518ca2660ac8c7e4979d (
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
|
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);
}
}
}
|