Any ideas?
void Update ()
{
int x = Screen.width / 2;
int y = Screen.height / 2;
Ray ray = playerCam.GetComponent<Camera>().ScreenPointToRay(new Vector3(x, y));
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
distance = hit.distance;
{
var p = hit.collider.GetComponent<Transform>(); //This isn't working :(
if (p != null && distance > -3.0f)
{
lookingAt = p.gameObject;
}
}
}