Hello all!
I have a class called HeroUnit that takes a BattleManager as an argument. In the BattleManager class, I am instantiating Heros from an array, however, I cant seem to figure out where to pass it a battlemanager object. I want to pass it the battlemanager object that its currently being instatiated from with ‘this’. The weird part is that this code creates the Gameobjects that have the HeroUnit script on it just fine and VisualStudio doesnt complain about them not taking a BattleManager as an argument. Any help would be MUCH appreciated! Here is an example:
public class HeroUnit : Unit
{
BattleManager battlemanager;
public HeroUnit(BattleManager newBattleManager)
{
battlemanager = newBattleManager;
}
}
public class BattleManager
{
public HeroUnit playerUnit;
public void BattleSetup()
{
Debug.Log("Creating Units now!");
// Create Heros at their spawn points and store them into variables.
CreateHeroes();
// Access the HeroUnit information on the Hero GameObjects and store them into variables.
playerUnit = createdHeroes[0].GetComponent<HeroUnit>();
}
void CreateHeroes()
{
if(party.currentParty.Count <= 3)
{
createdHeroes = new GameObject[party.currentParty.Count];
for (int i = 0; i < party.currentParty.Count; i++)
{
createdHeroes <em>= Instantiate(party.currentParty_, heroLocations*);*_</em>
}
}
}
}