New to Unity, working on an infectious disease simulation. I have a "patient" class to which I want to assign a "disease". To start, I just want to be able to print the patient's disease to console on spawn. How do I go about this? Here's my current attempt:
public class Disease : MonoBehaviour
{
public string[] diseases = new string[] {"Pneumonia", "Influenza", "Covid-19"};
}
public class Patient : MonoBehaviour
{
public Disease disease;
void Start()
{
disease = Disease.diseases[Random.Range(0, diseases.Length)];
Debug.Log("Patient has: " + disease);
}
}
I get these errors:
- error CS0120: An object reference is required for the non-static field, method, or property 'Disease.diseases'
- error CS0103: The name 'diseases' does not exist in the current context
Thanks.