private void reset() { VisibilityGraphGenerator.removePathVertex(destination); destination = Terrain.getValidSquare(); goal.transform.position = destination.pos; VisibilityGraphGenerator.addPathVertex(destination); // canReachGoal = canReachDestination(); walkToNearbyNeighbor = false; setPathPlan(); i = 0; }
// spawns agent and their destination square and gives the destination square to the agent void spawnAgents() { while (numberOfAgents-- > 0) { Vector3 spawnPoint = Terrain.getValidSquare().pos; Agent tempAgent = Instantiate(agentPrefab, spawnPoint, Quaternion.identity); PathVertex destinationPoint = Terrain.getValidSquare(); VisibilityGraphGenerator.addPathVertex(destinationPoint); tempAgent.setDestination(destinationPoint); GameObject goalSquare = Instantiate(goalPrefab, destinationPoint.pos, Quaternion.identity); tempAgent.setGoalSquare(goalSquare); // once our agent is spawned and has a destination, we make it walk and we forget about it // the rest of the code logic is delegated to Agent.cs } }