Files
2024-10-29 17:16:17 +01:00

26 lines
803 B
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using Unity.Netcode;
using UnityEngine;
// this script moves the name tag above the head
public class NameLabel : NetworkBehaviour
{
[SerializeField] private GameObject NameCanvas;
[SerializeField] private GameObject MainCamera;
private void Update()
{
//if you are owner of the player object this script is attached to, move the name tag relative to your position
// sync handled by PlayerComponent...Sync
if (IsOwner)
{
NameCanvas.transform.position = MainCamera.transform.position + Vector3.up * 0.625f;
NameCanvas.transform.rotation = Quaternion.EulerRotation(0, Quaternion.ToEulerAngles(MainCamera.transform.rotation).y + 135, 0);
}
}
}