void Start() { pathManager = GetComponent <PathManager>(); navHandler = GetComponent <NavMeshHandler>(); getHealth = GetComponent <Health>(); }
void Start() { //Get Components from AI navHandler = GetComponent <NavMeshHandler>(); pathManager = GetComponent <PathManager>(); lookChance = 10; }
private void _CreateMaze() { _mazeGameObject = new GameObject(); List <GameObject> _gameObjects = new List <GameObject>(); GameObject wallPrefab = (GameObject)Resources.Load("Wall"); GameObject floorPrefab = (GameObject)Resources.Load("Floor"); GameObject startPrefab = (GameObject)Resources.Load("Start"); GameObject targetPrefab = (GameObject)Resources.Load("Target"); int size = 51; bool[] isWalls = new MazeGenerator().Generate(size); for (int i = 0; i < isWalls.Length; i++) { int x = i % size; int z = i / size; if (isWalls[i]) { _gameObjects.Add(GameObject.Instantiate(wallPrefab, new Vector3(x, 1, z), Quaternion.identity)); } _gameObjects.Add(GameObject.Instantiate(floorPrefab, new Vector3(x, 0, z), Quaternion.identity)); } int startIndex = Random.Range(0, size * size); while (isWalls[startIndex]) { startIndex = Random.Range(0, size * size); } int endIndex = Random.Range(0, size * size); while (endIndex == startIndex || isWalls[endIndex]) { endIndex = Random.Range(0, size * size); } startPrefab = GameObject.Instantiate(startPrefab, new Vector3(startIndex % size, 1, startIndex / size), Quaternion.identity); targetPrefab = GameObject.Instantiate(targetPrefab, new Vector3(endIndex % size, 1, endIndex / size), Quaternion.identity); NavMeshHandler.Build(_gameObjects); _navMeshAgent = startPrefab.GetComponent <NavMeshAgent>(); _navMeshAgent.SetDestination(targetPrefab.transform.position); _endPosition = targetPrefab.transform.position; startPrefab.transform.parent = _mazeGameObject.transform; targetPrefab.transform.parent = _mazeGameObject.transform; for (int i = 0; i < _gameObjects.Count; i++) { _gameObjects[i].transform.parent = _mazeGameObject.transform; } }
void Start() { behaviourSetup = GetComponent <BehaviourSetup>(); navHandler = GetComponent <NavMeshHandler>(); rig = GetComponent <Rigidbody>(); aiPaths = GameObject.FindGameObjectsWithTag("Path"); //Int picks a random number between 0 and the array length index = Random.Range(0, aiPaths.Length); currentPath = aiPaths[index]; rig.useGravity = false; lastRandomNumber = index; }
void Start() { player = GameObject.FindGameObjectWithTag("Player"); navHandler = GetComponent <NavMeshHandler>(); pathManager = GetComponent <PathManager>(); }
void Start() { rig = GetComponent <Rigidbody>(); navHandler = GetComponent <NavMeshHandler>(); }