//Hold item in front of player, to be used or thrown away. Each item will have a different transform and //means of interaction. public GameObject HoldItem(int itemToHold) { float camOffset = .5f; ItemAttributes itemAttributes = inventoryItems [itemToHold].GetComponent <ItemAttributes> (); Vector3 itemPosition = fpsCam.ViewportToWorldPoint(itemAttributes.GetItemViewportLocation()); //The rotation x,y, and z values that the object will use. float rx = itemAttributes.GetXRotationOffset(); float ry = itemAttributes.GetYRotationOffset(); float rz = itemAttributes.GetZRotationOffset(); //Set up our position relative to the camera. GameObject newItem = (GameObject)Instantiate(inventoryItems [itemToHold], itemPosition, fpsCam.transform.rotation * Quaternion.Euler(rx, ry, rz), fpsCam.transform); //We must disable certain physical properties to make it usable by the player. newItem.GetComponent <Collider> ().enabled = false; newItem.GetComponent <Rigidbody> ().isKinematic = true; return(newItem); }