using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using TMPro; using UnityEngine; public class NameUIFollow : MonoBehaviour { public Collider RootParentCollider; public TextMeshProUGUI PlayersNameTag; private void Update() { if (Player.Instance.GetPlayerFirstPersonCamera()) { Plane[] planes = GeometryUtility.CalculateFrustumPlanes(Player.Instance.GetPlayerFirstPersonCamera()); bool isSeen = GeometryUtility.TestPlanesAABB(planes, RootParentCollider.bounds) && Vector3.Distance(RootParentCollider.gameObject.transform.position, Player.Instance.GetPlayerFirstPersonCameraPosition()) < 10.0f; PlayersNameTag.enabled = isSeen; } else { Debug.Log("Local Player First person camera is null. This should not happen."); } } private void LateUpdate() { if (Player.Instance != null) transform.rotation = Quaternion.LookRotation(transform.position - Player.Instance.GetPlayerFirstPersonCameraPosition()); } }