Full error: NullReferenceException: Object reference not set to an instance of an object
Inventory_Manager.Update () (at Assets/My Scripts/MainScene/Inventory System/Inventory_Manager.cs:105)
RaycastHit hit; //has all the info about the object (name, tag, component etc....)
Physics.Raycast(mainCamera.transform.position/*Origin*/, mainCamera.transform.forward/*Direction*/, out hit/*referenced hit*/, 3);
if (hit.collider.gameObject.tag == "Item") // <<----- LINE 105
{
lookingAtContainer = false;
showGUI = true; //show pickup prompt
pickupPrompt.text = "Hit E to pick up: " + hit.collider.gameObject.GetComponent<Item_Info>().itemName; //show pick up prompt "Hit E to pick up: " plus what ever item you're mlooking at. The raycast looks at the script and check the name given to the item
}
else if (hit.collider.gameObject.tag == "Container")
{
lookingAtContainer = true;
showGUI = true; //show pickup prompt
pickupPrompt.text = "Hit E to open the: " + hit.collider.gameObject.GetComponent<Object_Info>().objectName; //show pick up prompt "Hit E to pick up: " plus what ever item you're mlooking at. The raycast looks at the script and check the name given to the item
}
else
{
lookingAtContainer = false;
showGUI = false;
pickupPrompt.text = "";
}