So I am new to Unity and I am trying a little game.
I am getting a few errors; can someone help?
*
Code:*
`using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Stove : MonoBehaviour
{
public GameObject rawSteakPrefab;
public GameObject cookedSteakPrefab;
void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("Player"))
{
// Assume the player is carrying a raw steak
if (PlayerInventory.HasItem("RawSteak"))
{
PlayerInventory.RemoveItem("RawSteak");
StartCoroutine(CookSteak());
}
}
}
public List <GameObject> CookSteak()
{
// Simulate cooking time
yield return new WaitForSeconds(5f);
Instantiate(cookedSteakPrefab, transform.position, Quaternion.identity);
}
}
Errors:
1. AssetsStove.cs(15,17): error CS0103: The name ‘PlayerInventory’ does not exist in the current context
2. AssetsStove.cs(18,32): error CS1503: Argument 1: cannot convert from ‘System.Collections.Generic.List<UnityEngine.GameObject>’ to ‘string’
3. AssetsStove.cs(23,30): error CS1624: The body of ‘Stove.CookSteak()’ cannot be an iterator block because ‘List<GameObject>’ is not an iterator interface type
thanks!
I am trying out Unity (relatively new, 12 years old)
KLV is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.