Hello,
I have some problems trying to activate a panel pop-up when looking at a collectible item. Nothing happens when looking at the item. BTW the Object has the tag collectible.
public GameObject Interact;
(...)
private void CheckCrossHair()
{
Vector3 rayOrigin = new Vector3(0.5f, 0.5f, 0f);
float rayLength = 500f;
Ray ray = Camera.main.ViewportPointToRay(rayOrigin);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, rayLength))
{
if (hit.transform.tag == "collectible")
{
Interact.SetActive(true);
Debug.Log("Hit the axe");
}
else
{
if (Interact.activeSelf == true)
{
Interact.SetActive(false);
}
}
}
}