using Unity.Netcode; using Unity.VRTemplate; using UnityEngine; using XRMultiplayer; /// /// Represents a networked billboard that will always billboard towards the person who owns the object. /// [RequireComponent(typeof(TurnToFace))] public class NetworkBillboard : NetworkBehaviour { /// /// Billboard effect. /// TurnToFace m_TurnToFace; /// private void Start() { m_TurnToFace = GetComponent(); } /// /// Handles the change in the "isInteracting" state of the object. /// /// The previous value of the "isInteracting" state. /// The current value of the "isInteracting" state. public void IsHeldChanged(bool current) { if (current) { m_TurnToFace.enabled = true; if (XRINetworkGameManager.Instance.GetPlayerByID(NetworkObject.OwnerClientId, out XRINetworkPlayer player)) { m_TurnToFace.faceTarget = player.head; } } } /// /// Called when the object is selected or deselected. /// /// Indicates whether the object is selected or deselected. public void Selected(bool selected) { if (!selected) { m_TurnToFace.enabled = false; } } }