Hello,
I have a two scripts which i have connected. One is a battlesystem and the other is a script that sends information about an enemy to that battlesystem (the game has an overworld with a separate battle screen for turn based combat). The things that I want it to send are the enemy attributes, move list and a prefab which contains the enemy sprite and animations. At the moment the scripts work fine in transferring the attributes and move lists but not the prefab. I’ve had a look around and there seems to be a lot of questions and solutions regarding loading prefabs but I’m not sure if they fit with what I am trying to do, or whether what I am trying to do is the right thing.
Here is the ‘Send to Battle’ script:
public class EnemyBattleTransition : MonoBehaviour
{
public Attributes enemyAttributes;
public EnemyMoveList enemyMoveList;
public GameObject enemyPrefab;
public BattleSystem battleSystem;
public string sceneToLoad = “Battle Screen”;
public void SendToBattle()
{
//send info to battlesystem
battleSystem.SetupEnemy(enemyAttributes, enemyMoveList, enemyPrefab);
SceneManager.LoadScene(sceneToLoad);
}
and here is the part of the battle system which relates to it:
void Start()
{
GameObject player = Instantiate(playerPrefab, playerBattlestation) as GameObject;
GameObject enemy = Instantiate(enemyPrefab, enemyBattlestation) as GameObject;
playerAnimator = player.GetComponent<Animator>();
enemyAnimator = enemy.GetComponent<Animator>();
state = BattleState.START;
StartCoroutine(SetupBattle());
}
public void SetupEnemy(Attributes newEnemyAttributes, EnemyMoveList newEnemyMoveList, GameObject newEnemyPrefab)
{
enemyAttributes = newEnemyAttributes;
thisEnemyMoveList = newEnemyMoveList;
enemyPrefab = newEnemyPrefab;
}
So the SetupEnemy function is working to bring in attributes and enemymovelist but not the prefab.
Help?