Hey so I am trying to add an interact button when the player is close to an npc, I got the logic working I just need to reference the player but if I reference the prefab it doesnt work because the networkmanager spawns the player as a clone. How can I get a reference to that clone?
Thanks in advance
[SerializeField] private GameObject containerGameObject;
[SerializeField] private PlayerInteract playerInteract;
private void Update()
{
if (playerInteract.GetInteractableObject() != null)
{
Show();
}
else
{
Hide();
}
}
private void Show()
{
containerGameObject.SetActive(true);
}
private void Hide()
{
containerGameObject.SetActive(false);
}
I guess I can do that in update but its very expensive
if (playerInteract == null)
{
GameObject player = GameObject.FindWithTag("Player");
playerInteract = player.GetComponent<PlayerInteract>();
}
If the objects are instantiated prefabs...