Hello! I just started learning unity and I’m trying to detect when the player looks at something using raycast hit. However, the issue I’m facing is that every object basically gets ignored by it except for one plane that the character’s standing on. Here are some code snippets:
if (Physics.Raycast(cameraCenter, camera.forward, out hit, 100f, groundMask))
{
lookObject = hit.transform.gameObject;
print(lookObject);
} else
{
lookObject = null;
}
All of the objects are on the same layer