So I’m not sure why but I’m not getting the gameobject of a raycast that is being cast on it.
if (Input.GetButtonDown("Fire1"))
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit))
{
Debug.Log(hit.transform.gameObject);
}
}
I’ve been adding debugs everywhere and I know its all working properly, except the final if statement. Any idea why?