i have a class called,
[System.Serializable]
public class EnemyInformation{
//inside are public variables like
public int enemyID;
public enemyName;
}
I created another script that inherits monobehaviour and is a component of an empty game object called GameManager.
public class EnemyList:Monobehaviour { //inside are to variable intialized. public EnemyInformation[] forestEnemies; public EnemyInformation[] genericEnemies; } Through the inspector I assign values to these variables. what i can't figure out is how I'm supposed to reference variables like enemyID in a class like SpawnCharacters so far i have
public SpawnCharacters: ScriptableObject { public GameObject gameManager; public EnemyList enemList; public void SpawnEnemies () { enemList=gameManager.GetComponent ; switch (enemList.enemyID)//throws error. no reference in EnemyList to enemyID { ...spawn enemies based on enemyID ref } } }
What have I forgotten to do?
while writing this i think it maybe enemList[0].enemyID but i wanted it to be if an element in enemList has the enemyID=var then spawn this character.
Let me know what you think or if there is a better way of doing this. (I originally used get and set and made the enemies inherited constructors of class called characterclass.)
FYI im making a turnbased battle system and this is to spawn enemies on previous map AND use that enemy info to display UI Image enemyImage.
public class EnemyList:Monobehaviour { //inside are to variable intialized. public EnemyInformation[] forestEnemies; public EnemyInformation[] genericEnemies; } Through the inspector I assign values to these variables. what i can't figure out is how I'm supposed to reference variables like enemyID in a class like SpawnCharacters so far i have
public SpawnCharacters: ScriptableObject { public GameObject gameManager; public EnemyList enemList; public void SpawnEnemies () { enemList=gameManager.GetComponent ; switch (enemList.enemyID)//throws error. no reference in EnemyList to enemyID { ...spawn enemies based on enemyID ref } } }
What have I forgotten to do?
while writing this i think it maybe enemList[0].enemyID but i wanted it to be if an element in enemList has the enemyID=var then spawn this character.
Let me know what you think or if there is a better way of doing this. (I originally used get and set and made the enemies inherited constructors of class called characterclass.)
FYI im making a turnbased battle system and this is to spawn enemies on previous map AND use that enemy info to display UI Image enemyImage.