I've got an issue where a game object is spawned that doesn't work as well as an empty game object called "New Game Object".
I also have this error: UnityException: Transform child out of bounds
UnitStatistics.Awake () (at Assets/Scripts/UnitStatistics.cs:67)
UnityEngine.Object:Instantiate(GameObject, Vector3, Quaternion)
BattleController:Spawning() (at Assets/Scripts/BattleController.cs:124)
BattleController:Awake() (at Assets/Scripts/BattleController.cs:55)
The mentioned Functions: Unit Behaviour
public virtual void Awake ()
{
m_UnitStatistics = this.gameObject.GetComponent ();
BattleControllerHoldingObject = GameObject.FindGameObjectWithTag("ManagementScriptHolder");
m_BattleController = BattleControllerHoldingObject.gameObject.GetComponent ();
m_Animator = this.gameObject.GetComponent ();
PushBox = this.gameObject.GetComponent ();
MoveAcc = MoveMax / MoveSpeed;
Attack1MoveAcc = Attack1MoveMax / Attack1MoveSpeed;
}
----------
Battle Controller
void Awake ()
{
VictoryState = false;
Spawning();
m_OverallUnitList.AddRange(GameObject.FindGameObjectsWithTag("Unit"));
m_ActiveUnitList.AddRange(m_OverallUnitList);
TeamConditionStartup();
SpawnTeamPointSliders();
}
void Spawning ()
{
for (int i=0;i();
CSOBJSP1STAT.Team = TeamToSpawnAs[i];
CSOBJSP1STAT.m_Group = GroupToSpawnAs[i];
CSOBJSP1STAT.m_Faction = GroupToSpawnAs[i];
CSOBJSP1STAT.m_Authority = AuthorityToSpawnAs[i];
CSOBJSP1STAT.m_AugmentLevelList[0] = AugumentMAXHPLevel[i];
CSOBJSP1STAT.m_AugmentLevelList[1] = AugumentATTLevel[i];
CSOBJSP1STAT.m_AugmentLevelList[2] = AugumentHPREGENLevel[i];
CSOBJSP1STAT.m_AugmentLevelList[3] = AugumentSturdinessLevel[i];
break;
case 1:
GameObject CurrentSpawnedObjectSP2 = Instantiate (CurrentObjectToSpawn, m_Spawnpoints2[SpawnpointIndexToSpawnAt[i]].position, m_Spawnpoints2[SpawnpointIndexToSpawnAt[i]].rotation) as GameObject;
UnitStatistics CSOBJSP2STAT;
CSOBJSP2STAT = CurrentSpawnedObjectSP2.GetComponent();
CSOBJSP2STAT.Team = TeamToSpawnAs[i];
CSOBJSP2STAT.m_Group = GroupToSpawnAs[i];
CSOBJSP2STAT.m_Faction = GroupToSpawnAs[i];
CSOBJSP2STAT.m_Authority = AuthorityToSpawnAs[i];
CSOBJSP2STAT.m_AugmentLevelList[0] = AugumentMAXHPLevel[i];
CSOBJSP2STAT.m_AugmentLevelList[1] = AugumentATTLevel[i];
CSOBJSP2STAT.m_AugmentLevelList[2] = AugumentHPREGENLevel[i];
CSOBJSP2STAT.m_AugmentLevelList[3] = AugumentSturdinessLevel[i];
break;
case 2:
GameObject CurrentSpawnedObjectSP3 = Instantiate (CurrentObjectToSpawn, m_Spawnpoints3[SpawnpointIndexToSpawnAt[i]].position, m_Spawnpoints3[SpawnpointIndexToSpawnAt[i]].rotation) as GameObject;
UnitStatistics CSOBJSP3STAT;
CSOBJSP3STAT = CurrentSpawnedObjectSP3.GetComponent();
CSOBJSP3STAT.Team = TeamToSpawnAs[i];
CSOBJSP3STAT.m_Group = GroupToSpawnAs[i];
CSOBJSP3STAT.m_Faction = GroupToSpawnAs[i];
CSOBJSP3STAT.m_Authority = AuthorityToSpawnAs[i];
CSOBJSP3STAT.m_AugmentLevelList[0] = AugumentMAXHPLevel[i];
CSOBJSP3STAT.m_AugmentLevelList[1] = AugumentATTLevel[i];
CSOBJSP3STAT.m_AugmentLevelList[2] = AugumentHPREGENLevel[i];
CSOBJSP3STAT.m_AugmentLevelList[3] = AugumentSturdinessLevel[i];
break;
case 3:
GameObject CurrentSpawnedObjectSP4 = Instantiate (CurrentObjectToSpawn, m_Spawnpoints4[SpawnpointIndexToSpawnAt[i]].position, m_Spawnpoints4[SpawnpointIndexToSpawnAt[i]].rotation) as GameObject;
UnitStatistics CSOBJSP4STAT;
CSOBJSP4STAT = CurrentSpawnedObjectSP4.GetComponent();
CSOBJSP4STAT.Team = TeamToSpawnAs[i];
CSOBJSP4STAT.m_Group = GroupToSpawnAs[i];
CSOBJSP4STAT.m_Faction = GroupToSpawnAs[i];
CSOBJSP4STAT.m_Authority = AuthorityToSpawnAs[i];
CSOBJSP4STAT.m_AugmentLevelList[0] = AugumentMAXHPLevel[i];
CSOBJSP4STAT.m_AugmentLevelList[1] = AugumentATTLevel[i];
CSOBJSP4STAT.m_AugmentLevelList[2] = AugumentHPREGENLevel[i];
CSOBJSP4STAT.m_AugmentLevelList[3] = AugumentSturdinessLevel[i];
break;
case 4:
GameObject CurrentSpawnedObjectSP5 = Instantiate (CurrentObjectToSpawn, m_Spawnpoints5[SpawnpointIndexToSpawnAt[i]].position, m_Spawnpoints5[SpawnpointIndexToSpawnAt[i]].rotation) as GameObject;
UnitStatistics CSOBJSP5STAT;
CSOBJSP5STAT = CurrentSpawnedObjectSP5.GetComponent();
CSOBJSP5STAT.Team = TeamToSpawnAs[i];
CSOBJSP5STAT.m_Group = GroupToSpawnAs[i];
CSOBJSP5STAT.m_Faction = GroupToSpawnAs[i];
CSOBJSP5STAT.m_Authority = AuthorityToSpawnAs[i];
CSOBJSP5STAT.m_AugmentLevelList[0] = AugumentMAXHPLevel[i];
CSOBJSP5STAT.m_AugmentLevelList[1] = AugumentATTLevel[i];
CSOBJSP5STAT.m_AugmentLevelList[2] = AugumentHPREGENLevel[i];
CSOBJSP5STAT.m_AugmentLevelList[3] = AugumentSturdinessLevel[i];
break;
case 5:
GameObject CurrentSpawnedObjectSP6 = Instantiate (CurrentObjectToSpawn, m_Spawnpoints6[SpawnpointIndexToSpawnAt[i]].position, m_Spawnpoints6[SpawnpointIndexToSpawnAt[i]].rotation) as GameObject;
UnitStatistics CSOBJSP6STAT;
CSOBJSP6STAT = CurrentSpawnedObjectSP6.GetComponent();
CSOBJSP6STAT.Team = TeamToSpawnAs[i];
CSOBJSP6STAT.m_Group = GroupToSpawnAs[i];
CSOBJSP6STAT.m_Faction = GroupToSpawnAs[i];
CSOBJSP6STAT.m_Authority = AuthorityToSpawnAs[i];
CSOBJSP6STAT.m_AugmentLevelList[0] = AugumentMAXHPLevel[i];
CSOBJSP6STAT.m_AugmentLevelList[1] = AugumentATTLevel[i];
CSOBJSP6STAT.m_AugmentLevelList[2] = AugumentHPREGENLevel[i];
CSOBJSP6STAT.m_AugmentLevelList[3] = AugumentSturdinessLevel[i];
break;
}
}
}
----------
I've been trying to figure out what to do about this to no avail. Ohh and I don't know for sure but these scripts probably aren't the most efficient.
↧