Example #1
0
    private void GatherFood()
    {
        RaycastHit hitInfo;

        if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hitInfo, Mathf.Infinity))
        {
            IngredientIdentifier foodToAdd = hitInfo.collider.GetComponentInParent <IngredientIdentifier>();
            if (foodToAdd != null)
            {
                if (inventory.AddFood(foodToAdd.GetFoodType()) && !foodToAdd.GetSource())
                {
                    Destroy(foodToAdd.gameObject);
                }
            }
        }
    }