public void spawnAI() { if (!GameManager.GM.RoundBegin) { if (UseNetwork) { NeuralNetController myNet = NeuralNetController.NNC; int NetworkAiToSpawn = Mathf.RoundToInt(Mathf.Lerp(MinAIToSpawn, MaxAIToSpawn, myNet.Outputs[(int)NetworkOutputNames.NumAi])); int DetectionRadius = Mathf.RoundToInt(Mathf.Lerp(MinDetectionRadius, MaxDetectionRadius, myNet.Outputs[(int)NetworkOutputNames.DetectionRadius])); bool CanAim = myNet.Outputs[(int)NetworkOutputNames.CanAim] > 0.5f; float Accuracy = Mathf.Lerp(MinAccuracy, MaxAccuracy, myNet.Outputs[(int)NetworkOutputNames.Accuracy]); int numGoals = Mathf.RoundToInt(Mathf.Lerp(1, 4, myNet.Outputs[(int)NetworkOutputNames.Goals])); BaseWeapon WeaponForAI = Weapons[Mathf.RoundToInt(Mathf.Lerp(0, Weapons.Count - 1, myNet.Outputs[(int)NetworkOutputNames.Weapon]))]; float MaxHealth = Mathf.Lerp(50, 200, myNet.Outputs[(int)NetworkOutputNames.MaxHealth]); for (int i = 0; i < NetworkAiToSpawn; ++i) { // Get Position within Next Area. GameObject nAI = Instantiate(AIPrefab, GetRandomPosition(), Quaternion.identity, transform); GoapAgent tempAgent = nAI.GetComponent <GoapAgent>(); AddGoals(ref tempAgent, numGoals); GoapAI myAIComp = nAI.GetComponent <GoapAI>(); myAIComp.DetectionRadius = DetectionRadius; myAIComp.CanAimWeapon = CanAim; myAIComp.LookAccuracy = Accuracy; myAIComp.AddWeapon(WeaponForAI); myAIComp.myDetectionObj.GetComponent <SphereCollider>().radius = DetectionRadius; Health AIHealth = nAI.GetComponent <Health>(); AIHealth.MaxHealth = MaxHealth; SpawnedAI.Add(myAIComp); tempAgent.Initialise(); myAIComp.Initialise(); } GameManager.GM.AIRemaining = NetworkAiToSpawn; GameManager.GM.RoundBegin = true; GameManager.GM.UpdateAICount(); } } }