private void Awake() { health = GetComponent <Health>(); stateSystems.Add(new AIShooterStateSystemAnimator(animatorProps, GetComponent <Animator>())); stateSystems.Add(new AIShooterStateSystemLookAt(lookIKProps)); stateSystems.Add(new AIShooterStateSystemMove(movementProps, patrolRoute)); stateSystems.Add(new AIShooterStateSystemWeapon(fireProps, weaponHandIKProps)); states.Add(new IdleState(stateSystems.ToArray())); states.Add(new AnimateState(stateSystems.ToArray())); states.Add(new MoveState(stateSystems.ToArray())); sensorSet.sensorList.RemoveAll(x => x == null); systemSet.systemList.RemoveAll(x => x == null); actionSet.actionList.RemoveAll(x => x == null); goalSet.goalList.RemoveAll(x => x == null); if (sensorSet == null || systemSet == null || goalSet == null || actionSet == null) { #if UNITY_EDITOR Debug.Log("You need to fill all sets"); #endif this.enabled = false; return; } List <AISensor> cloneSensors = new List <AISensor>(); foreach (AISensor sensor in sensorSet.sensorList) { cloneSensors.Add(UnityEngine.Object.Instantiate(sensor) as AISensor); } List <AIAction> cloneActions = new List <AIAction>(); foreach (AIAction action in actionSet.actionList) { cloneActions.Add(UnityEngine.Object.Instantiate(action) as AIAction); } List <AISystem> cloneSystems = new List <AISystem>(); foreach (AISystem system in systemSet.systemList) { cloneSystems.Add(UnityEngine.Object.Instantiate(system) as AISystem); } List <AIGoal> cloneGoals = new List <AIGoal>(); foreach (AIGoal goal in goalSet.goalList) { cloneGoals.Add(UnityEngine.Object.Instantiate(goal) as AIGoal); } AIMemoryShooter memory = new AIMemoryShooter(gameObject, 150, 2, 25, friendMask); GetComponent <SharedProps>().memory = memory; ai = new AIBrain( cloneSensors, cloneSystems, cloneActions, cloneGoals, states, stateSystems, brainProps, transform, memory, ref onAgentDead ); ai.OnAwake(); footSoundFx = new FootPlanting(footStepFx, GetComponent <Animator>()); }