I have this code: It’s an item class to put it simply. But I want to check (on collision) whether the gameobject is in this array. Here is what I tried, it makes sense in my head but I don’t think it will work:
[System.Serializable]
public class Cookable
{
public string name;
public GameObject uncookedModel;
public GameObject cookedModel;
public GameObject burntModel;
// Make a constructor
public Cookable(string name, GameObject uncooked, GameObject cooked, GameObject burnt)
{
this.name = name;
this.uncookedModel = uncooked;
this.cookedModel = cooked;
this.burntModel = burnt;
}
}
public class Grill : MonoBehaviour
{
/// <summary>
/// An array of cookable gameobject prefabs. They each have an uncooked, cooked and burnt texture.
/// </summary>
public Cookable[] cookables;
private void OnCollisionStay(Collision collision)
{
foreach(var c in cookables)
{
}
}
}