//public void Init (AnimationAnalyzer animAnalyzer, AnimationEngine animEngine, FootstepPlanningTest planner, public void Init(AnimationAnalyzer animAnalyzer, AnimationEngine animEngine, Planner planner, NeighbourAgents agents, NeighbourObstacles obstacles, CollisionReaction colReact) { analyzer = animAnalyzer; if (analyzer != null && !analyzer.initialized) { analyzer.Init(); } planning = planner; if (planning != null && !planning.initialized) { planning.Init(analyzer, agents, obstacles); } engine = animEngine; if (engine != null && !engine.initialized) { engine.Init(analyzer, planning, agents, obstacles); } collision = colReact; if (collision != null && !collision.initialized) { collision.Init(analyzer, planning, engine, agents, obstacles); } if (debugText != null) { debugText.gameObject.active = false; } initialized = true; }
//public void Init(AnimationAnalyzer analyzer, FootstepPlanningTest planner, public void Init(AnimationAnalyzer analyzer, Planner planner, AnimationEngine animEngine, CollisionReaction collisionReact, NavMeshWayPoints navMeshWaypoints, SteeringManager steering, NeighbourAgents agents, NeighbourObstacles obstacles, PlaceFootSteps steps) { planning = planner; if (planning != null && !planning.initialized) { planning.Init(analyzer, agents, obstacles); } engine = animEngine; if (engine != null && !engine.initialized) { engine.Init(analyzer, planning, agents, obstacles); } collision = collisionReact; if (collision != null && !collision.initialized) { collision.Init(analyzer, planner, engine, agents, obstacles); } waypoints = navMeshWaypoints; //if (waypoints != null && !waypoints.initialized) // waypoints.Init(planning,steering,analyzer,agents,obstacles); neighborhood = agents; if (neighborhood != null && !neighborhood.initialized) { neighborhood.Init(); } footsteps = steps; if (footsteps != null && !footsteps.initiated) { footsteps.Init(analyzer, planner, engine, neighborhood, obstacles); } nObstacles = obstacles; if (nObstacles != null && !nObstacles.initialized) { nObstacles.Init(); } timeSinceLastPlan = 0; timeSinceLastWaypoints = 0; previousGoalPosition = planning.goalStateTransform.position; previousCurrentGoalPosition = planning.currentGoal; previousActionsSinceLastPlan = -1; newWaypoint = false; initialized = true; }
void OnTriggerExit(Collider other) { NeighbourObstacles no = other.transform.parent.gameObject.GetComponent("NeighbourObstacles") as NeighbourObstacles; if (no != null) { no.HasLostSight(this.gameObject); } }
//public GridTimeDomain(AnimationAnalyzer animAnalyzer, NeighbourObstacles o) public GridTimeDomain(NeighbourObstacles o, NeighbourAgents n) { //analyzer = animAnalyzer; neighborhood = n; obstacles = o; #if USE_ANGLE_MOV movAngles = new List<float>(); movAngles.Add(0.0f); movAngles.Add(22.5f); movAngles.Add(-22.5f); movAngles.Add(45.0f); movAngles.Add(-45.0f); movAngles.Add(180.0f); movAngles.Add(157.5f); movAngles.Add(-157.5f); #else Vector3 dir1 = new Vector3(1,0,0); Vector3 dir2 = new Vector3(-1,0,0); Vector3 dir3 = new Vector3(0,0,1); Vector3 dir4 = new Vector3(0,0,-1); Vector3 dir5 = new Vector3(-1,0,-1); dir5.Normalize(); Vector3 dir6 = new Vector3(-1,0,1); dir6.Normalize(); Vector3 dir7 = new Vector3(1,0,-1); dir7.Normalize(); Vector3 dir8 = new Vector3(1,0,1); dir8.Normalize(); movDirections = new List<Vector3>(); movDirections.Add(dir1); movDirections.Add(dir2); movDirections.Add(dir3); movDirections.Add(dir4); movDirections.Add(dir5); movDirections.Add(dir6); movDirections.Add(dir7); movDirections.Add(dir8); #endif possibleSpeedIncrements = new List<float>(); possibleSpeedIncrements.Add(0.0f); possibleSpeedIncrements.Add(SPEED_DELTA); possibleSpeedIncrements.Add(-SPEED_DELTA); useTunnel = false; }
void Awake() { // Check license // 1) Initialize world --> obstacles // 2) Instantiate agents and final goals /* * agents = new GameObject[numberOfAgents]; * for (int id = 0; id < numberOfAgents; id++) * { * agents[id] = new GameObject("Agent"+id); * agents[id].AddComponent(NewManPrefab); * } */ agents = GameObject.FindGameObjectsWithTag("Agent"); // 3) Generate NavMesh (ang goals/waypoints?) agentsPos = new Vector3[agents.Length]; agentsInit = new bool[agents.Length]; //foreach (GameObject agent in agents) for (int i = 0; i < agents.Length; i++) { GameObject agent = agents[i]; //agent.active = false; agentsPos[i] = agent.transform.position; agent.transform.position = new Vector3(int.MaxValue, int.MaxValue, int.MaxValue); agentsInit[i] = false; NeighbourAgents neighbourAgents = agent.GetComponent("NeighbourAgents") as NeighbourAgents; if (neighbourAgents != null) { neighbourAgents.Init(); } NeighbourObstacles neighbourObstacles = agent.GetComponent("NeighbourObstacles") as NeighbourObstacles; if (neighbourObstacles != null) { neighbourObstacles.Init(); } } initCount = 0; }
// Use this for initialization //public void Init (FootstepPlanningTest planner, SteeringManager steeringManager, AnimationAnalyzer analyzer, NeighbourAgents agents, NeighbourObstacles obstacles, RootMotionComputer computer) { public void Init(Planner planner, SteeringManager steeringManager, AnimationAnalyzer analyzer, NeighbourAgents agents, NeighbourObstacles obstacles) { steering = steeringManager; planning = planner; if (planning != null && !planning.initialized) planning.Init(analyzer, agents, obstacles); navMeshLayer = 1 << LayerMask.NameToLayer("StaticWorld"); initialized = true; }
//public GridTimeDomain(AnimationAnalyzer animAnalyzer, NeighbourObstacles o) public GridTimeDomain(NeighbourObstacles o, NeighbourAgents n) { //analyzer = animAnalyzer; neighborhood = n; obstacles = o; #if USE_ANGLE_MOV movAngles = new List <float>(); movAngles.Add(0.0f); movAngles.Add(22.5f); movAngles.Add(-22.5f); movAngles.Add(45.0f); movAngles.Add(-45.0f); movAngles.Add(180.0f); movAngles.Add(157.5f); movAngles.Add(-157.5f); #else Vector3 dir1 = new Vector3(1, 0, 0); Vector3 dir2 = new Vector3(-1, 0, 0); Vector3 dir3 = new Vector3(0, 0, 1); Vector3 dir4 = new Vector3(0, 0, -1); Vector3 dir5 = new Vector3(-1, 0, -1); dir5.Normalize(); Vector3 dir6 = new Vector3(-1, 0, 1); dir6.Normalize(); Vector3 dir7 = new Vector3(1, 0, -1); dir7.Normalize(); Vector3 dir8 = new Vector3(1, 0, 1); dir8.Normalize(); movDirections = new List <Vector3>(); movDirections.Add(dir1); movDirections.Add(dir2); movDirections.Add(dir3); movDirections.Add(dir4); movDirections.Add(dir5); movDirections.Add(dir6); movDirections.Add(dir7); movDirections.Add(dir8); #endif possibleSpeedIncrements = new List <float>(); possibleSpeedIncrements.Add(0.0f); possibleSpeedIncrements.Add(SPEED_DELTA); possibleSpeedIncrements.Add(-SPEED_DELTA); useTunnel = false; }
//public void Init(AnimationAnalyzer analyzer, FootstepPlanningTest planner, public void Init(AnimationAnalyzer analyzer, Planner planner, AnimationEngine animEngine, CollisionReaction collisionReact, NavMeshWayPoints navMeshWaypoints, SteeringManager steering, NeighbourAgents agents, NeighbourObstacles obstacles, PlaceFootSteps steps) { planning = planner; if (planning != null && !planning.initialized) planning.Init(analyzer,agents,obstacles); engine = animEngine; if (engine != null && !engine.initialized) engine.Init(analyzer,planning,agents,obstacles); collision = collisionReact; if (collision != null && !collision.initialized) collision.Init(analyzer,planner,engine,agents,obstacles); waypoints = navMeshWaypoints; //if (waypoints != null && !waypoints.initialized) // waypoints.Init(planning,steering,analyzer,agents,obstacles); neighborhood = agents; if (neighborhood != null && !neighborhood.initialized) neighborhood.Init(); footsteps = steps; if (footsteps != null && !footsteps.initiated) footsteps.Init(analyzer,planner,engine,neighborhood,obstacles); nObstacles = obstacles; if (nObstacles != null && !nObstacles.initialized) nObstacles.Init(); timeSinceLastPlan = 0; timeSinceLastWaypoints = 0; previousGoalPosition = planning.goalStateTransform.position; previousCurrentGoalPosition = planning.currentGoal; previousActionsSinceLastPlan = -1; newWaypoint = false; initialized = true; }
//public void Init(AnimationAnalyzer animAnalyzer, FootstepPlanningTest planner, AnimationEngine animEngine, public void Init(AnimationAnalyzer animAnalyzer, Planner planner, AnimationEngine animEngine, NeighbourAgents agents, NeighbourObstacles obstacles) { analyzer = animAnalyzer; if (analyzer != null && !analyzer.initialized) { analyzer.Init(); } planning = planner; if (planning != null && !planning.initialized) { planning.Init(analyzer, agents, obstacles); } engine = animEngine; if (engine != null && !engine.initialized) { engine.Init(analyzer, planning, agents, obstacles); } if (rightFoot.position[1] < leftFoot.position[1]) { auxHeight = rightFoot.position[1]; } else { auxHeight = leftFoot.position[1]; } counter = 0; footSteps = new Object[numberOfFootSteps]; initiated = true; }
//public void Init (AnimationAnalyzer animAnalyzer, AnimationEngine animEngine, FootstepPlanningTest planner, public void Init(AnimationAnalyzer animAnalyzer, AnimationEngine animEngine, Planner planner, NeighbourAgents agents, NeighbourObstacles obstacles, CollisionReaction colReact) { analyzer = animAnalyzer; if (analyzer != null && !analyzer.initialized) analyzer.Init(); planning = planner; if (planning != null && !planning.initialized) planning.Init(analyzer, agents, obstacles); engine = animEngine; if (engine != null && !engine.initialized) engine.Init(analyzer,planning,agents,obstacles); collision = colReact; if (collision != null && !collision.initialized) collision.Init(analyzer,planning,engine,agents,obstacles); if (debugText != null) debugText.gameObject.active = false; initialized = true; }
public FootstepPlanningDomain(AnimationAnalyzer animAnalyzer, NeighbourAgents n, NeighbourObstacles o) { analyzer = animAnalyzer; neighborhood = n; obstacles = o; }
//public void Init(AnimationAnalyzer animAnalyzer, FootstepPlanningTest planner, AnimationEngine animEngine, NeighbourAgents agents, NeighbourObstacles obstacles) public void Init(AnimationAnalyzer animAnalyzer, Planner planner, AnimationEngine animEngine,NeighbourAgents agents, NeighbourObstacles obstacles) { analyzer = animAnalyzer; if (analyzer != null && !analyzer.initialized) analyzer.Init(); planning = planner; if (planning != null && !planning.initialized) planning.Init(analyzer, agents, obstacles); engine = animEngine; if (engine != null && !engine.initialized) engine.Init(analyzer,planning, agents, obstacles); reacting = false; initialized = true; }
//////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// // Use this for initialization public void InitializeAgentBrain() { // NAV MESH AGENT TEST GetComponent<NavMeshAgent>().Stop (); GetComponent<NavMeshAgent>().updatePosition = false; GetComponent<NavMeshAgent>().updateRotation = false; locomotionSystem = GetComponent<SoldierLocomotion>(); // initializing neighbor lists neighborObstacles = GetComponent<NeighbourObstacles>(); neighborObstacles.Init (); neighborAgents = GetComponent<NeighbourAgents>(); neighborAgents.Init(); currentState = new State(transform.position); if (GlobalNavigator.usingDynamicNavigationMesh) { currentPolygonIndex = GlobalNavigator.recastSteeringManager.GetClosestPolygon(currentState.getPosition()); } if ( goal == null ) Debug.LogError("Goal has not been initialized for this agent"); goalState = goal.goalState; passableMask = 1; // this could be part of the goal globalPath = new List<State> (); numGlobalPathWaypoints = 0; globalPathPolygonIndices = new List<uint> (); localPaths = new List<List<State>> (); spaceTimePaths = new List<List<State>> (); currentPlanExecutionIndex = 0; offMeshLinkWayPoint = new List<bool>(); taskManager = new TaskManager (); // creating global navigation task globalNavigationTask = new GlobalNavigationtask(currentState,goalState,passableMask, TaskPriority.RealTime, taskManager); globalNavigationTask.taskName = "globalNavigationTask"; // EVENT: AgentBrain is triggered by the globalNavigationTask when GLOBAL_PATH_CHANGED globalNavigationTask.registerObserver(Event.GLOBAL_PATH_CHANGED, this); gridNavigationTasks = new List<GridNavigationTask>(); // creating grid navigation and grid time tasks for each statically allocated global waypoint // -- we can statically allocate how many ever we want for (int i=0; i < 1; i ++ ) { _addNewEmptyGlobalPathWayPointAtIndex(i); } curves = new AnimationCurve[4]; curves[0] = new AnimationCurve(); // x curves[1] = new AnimationCurve(); // y curves[2] = new AnimationCurve(); // z curves[3] = new AnimationCurve(); // speed }
// Use this for initialization public override void Init(AnimationAnalyzer animAnalyzer, NeighbourAgents neighborhood, NeighbourObstacles obstacles) { analyzer = animAnalyzer; if (analyzer != null && !analyzer.initialized) { analyzer.Init(); } storedPlan = new List <FootstepPlanningAction>(); outputPlan = new Stack <DefaultAction>(); domainList = new List <PlanningDomainBase>(); domainList.Add(new FootstepPlanningDomain(analyzer, neighborhood, obstacles)); planner = new ADAstarPlanner(); planner.init(ref domainList, MaxNumberOfNodes); initialized = true; currentState = null; isPlanComputed = false; planChanged = false; goalMeshRenderer = goalStateTransform.gameObject.GetComponent("MeshRenderer") as MeshRenderer; currentGoal = goalStateTransform.position; }
//public void Init(AnimationAnalyzer animAnalyzer, FootstepPlanningTest planner, AnimationEngine animEngine, public void Init(AnimationAnalyzer animAnalyzer, Planner planner, AnimationEngine animEngine, NeighbourAgents agents, NeighbourObstacles obstacles) { analyzer = animAnalyzer; if (analyzer != null && !analyzer.initialized) analyzer.Init(); planning = planner; if (planning != null && !planning.initialized) planning.Init(analyzer, agents, obstacles); engine = animEngine; if (engine != null && !engine.initialized) engine.Init(analyzer,planning,agents,obstacles); if (rightFoot.position[1] < leftFoot.position[1]) auxHeight = rightFoot.position[1]; else auxHeight = leftFoot.position[1]; counter = 0; footSteps = new Object[numberOfFootSteps]; initiated = true; }
//public void Init(AnimationAnalyzer animAnalyzer, FootstepPlanningTest planner, RootMotionComputer computer, NeighbourAgents agents, NeighbourObstacles obstacles){ public void Init(AnimationAnalyzer animAnalyzer, Planner planner, NeighbourAgents agents, NeighbourObstacles obstacles) { analyzer = animAnalyzer; if (analyzer != null && !analyzer.initialized) { analyzer.Init(); } planning = planner; if (planning != null && !planning.initialized) { planning.Init(analyzer, agents, obstacles); } foreach (AnimationState state in animation) { state.enabled = true; state.speed = 1.0f; state.wrapMode = WrapMode.Loop; state.weight = 0; } currentAnimation = null; action = null; animation.Stop(); initialized = true; actionNum = 0; changed = false; errorT = new Vector3(0, 0, 0); errorR = 0; currentBlendingTime = 0; currentActionTime = 0; previousBlendingTime = 0; currentActionEndTime = 0; actionsSinceLastPlan = 0; insertedAction = false; initGameObjectPos = transform.position; initGameObjectRotY = transform.eulerAngles.y; initLocalRootPos = root.localPosition; lastRootPos = root.position; lastRootRot = root.rotation; }
// Use this for initialization void InitAgent(int i) { AnimationAnalyzer analyzer = null; // Initialize different components of the agents // ( Animation Engine, Planner, Neighbors, ...) //foreach (GameObject agent in agents) //for(int i = 0; i < agents.Length; i++) { GameObject agent = agents[i]; //agent.active = true; agent.transform.position = agentsPos[i]; //if (analyzer == null) { analyzer = agent.GetComponent("AnimationAnalyzer") as AnimationAnalyzer; if (analyzer != null) { analyzer.Init(); //analyzer.ReadAnalysisFromFile(animationsFileName); } } /* * else * { * Vector3 startPos = agent.transform.position; * Quaternion startRot = agent.transform.rotation; * analyzer.RemoveAnimations(agent.animation); * agent.transform.position = startPos; * agent.transform.rotation = startRot; * } */ NeighbourAgents neighbourAgents = agent.GetComponent("NeighbourAgents") as NeighbourAgents; //if (neighbourAgents != null) // neighbourAgents.Init(); NeighbourObstacles neighbourObstacles = agent.GetComponent("NeighbourObstacles") as NeighbourObstacles; //if (neighbourObstacles != null) // neighbourObstacles.Init(); Planner planning; if (ADAFootstepTest.ADA_PLANNER_IN_USE) { ADAFootstepTest ADAplanning = agent.GetComponent("ADAFootstepTest") as ADAFootstepTest; planning = ADAplanning as Planner; } else { FootstepPlanningTest FPTplanning = agent.GetComponent("FootstepPlanningTest") as FootstepPlanningTest; planning = FPTplanning as Planner; } if (planning != null) { planning.Init(analyzer, neighbourAgents, neighbourObstacles); } AnimationEngine engine = agent.GetComponent("AnimationEngine") as AnimationEngine; if (engine != null) { engine.Init(analyzer, planning, neighbourAgents, neighbourObstacles); } CollisionReaction collider = agent.GetComponent("CollisionReaction") as CollisionReaction; if (collider != null) { collider.Init(analyzer, planning, engine, neighbourAgents, neighbourObstacles); } NavMeshWayPoints waypoints = agent.GetComponent("NavMeshWayPoints") as NavMeshWayPoints; if (waypoints != null) { waypoints.Init(planning, steering, analyzer, neighbourAgents, neighbourObstacles); } PlaceFootSteps footsteps = agent.GetComponent("PlaceFootSteps") as PlaceFootSteps; if (footsteps != null) { footsteps.Init(analyzer, planning, engine, neighbourAgents, neighbourObstacles); } EventsMonitor events = agent.GetComponent("EventsMonitor") as EventsMonitor; if (events != null) { events.Init(analyzer, planning, engine, collider, waypoints, steering, neighbourAgents, neighbourObstacles, footsteps); events.enabled = false; } DebugScript debug = agent.GetComponent("DebugScript") as DebugScript; if (debug != null) { debug.Init(analyzer, engine, planning, neighbourAgents, neighbourObstacles, collider); } if (analyzer != null) { analyzer.RemoveAnimations(agent.animation); } } }
// Use this for initialization public override void Init(AnimationAnalyzer animAnalyzer, NeighbourAgents neighborhood, NeighbourObstacles obstacles) { analyzer = animAnalyzer; if (analyzer != null && !analyzer.initialized) analyzer.Init(); storedPlan = new List<FootstepPlanningAction>(); outputPlan = new Stack<DefaultAction>(); domainList = new List<PlanningDomainBase>(); domainList.Add(new FootstepPlanningDomain(analyzer, neighborhood, obstacles)); planner = new ADAstarPlanner(); planner.init(ref domainList, MaxNumberOfNodes); initialized = true; currentState = null; isPlanComputed = false; planChanged = false; goalMeshRenderer = goalStateTransform.gameObject.GetComponent("MeshRenderer") as MeshRenderer; currentGoal = goalStateTransform.position; }
// Use this for initialization public override void Init(AnimationAnalyzer animAnalyzer, NeighbourAgents neighborhood, NeighbourObstacles obstacles) { analyzer = animAnalyzer; if (analyzer != null && !analyzer.initialized) analyzer.Init(); storedPlan = new List<FootstepPlanningAction>(); outputPlan = new Stack<DefaultAction>(); domainList = new List<PlanningDomainBase>(); gpd = new GridPlanningDomain(analyzer); //gtd = new GridTimeDomain(analyzer, obstacles); gtd = new GridTimeDomain(obstacles,neighborhood); fpd = new FootstepPlanningDomain(analyzer, neighborhood, obstacles); if (useGridDomain) { domainList.Add(gpd); //domainList.Add(gpd); } if (useGridTimeDomain) { domainList.Add(gtd); //domainList.Add(gtd); } if (useFootstepDomain) { domainList.Add(fpd); //domainList.Add(fpd); } planner = new BestFirstSearchPlanner(); planner.init(ref domainList, MaxNumberOfNodes); initialized = true; currentState = null; isPlanComputed = false; planChanged = false; goalMeshRenderer = goalStateTransform.gameObject.GetComponent("MeshRenderer") as MeshRenderer; currentGoal = goalStateTransform.position; goalReached = false; }
// Use this for initialization //public void Init (FootstepPlanningTest planner, SteeringManager steeringManager, AnimationAnalyzer analyzer, NeighbourAgents agents, NeighbourObstacles obstacles, RootMotionComputer computer) { public void Init(Planner planner, SteeringManager steeringManager, AnimationAnalyzer analyzer, NeighbourAgents agents, NeighbourObstacles obstacles) { steering = steeringManager; planning = planner; if (planning != null && !planning.initialized) { planning.Init(analyzer, agents, obstacles); } navMeshLayer = 1 << LayerMask.NameToLayer("StaticWorld"); initialized = true; }
//public void Init(AnimationAnalyzer animAnalyzer, FootstepPlanningTest planner, AnimationEngine animEngine, NeighbourAgents agents, NeighbourObstacles obstacles) public void Init(AnimationAnalyzer animAnalyzer, Planner planner, AnimationEngine animEngine, NeighbourAgents agents, NeighbourObstacles obstacles) { analyzer = animAnalyzer; if (analyzer != null && !analyzer.initialized) { analyzer.Init(); } planning = planner; if (planning != null && !planning.initialized) { planning.Init(analyzer, agents, obstacles); } engine = animEngine; if (engine != null && !engine.initialized) { engine.Init(analyzer, planning, agents, obstacles); } reacting = false; initialized = true; }
public virtual void Init(AnimationAnalyzer aa, NeighbourAgents na, NeighbourObstacles no) { }
//public void Init(AnimationAnalyzer animAnalyzer, FootstepPlanningTest planner, RootMotionComputer computer, NeighbourAgents agents, NeighbourObstacles obstacles){ public void Init(AnimationAnalyzer animAnalyzer, Planner planner, NeighbourAgents agents, NeighbourObstacles obstacles) { analyzer = animAnalyzer; if (analyzer != null && !analyzer.initialized) analyzer.Init(); planning = planner; if (planning != null && !planning.initialized) planning.Init(analyzer,agents,obstacles); foreach (AnimationState state in animation) { state.enabled = true; state.speed = 1.0f; state.wrapMode = WrapMode.Loop; state.weight = 0; } currentAnimation = null; action = null; animation.Stop(); initialized = true; actionNum = 0; changed = false; errorT = new Vector3(0,0,0); errorR = 0; currentBlendingTime = 0; currentActionTime = 0; previousBlendingTime = 0; currentActionEndTime = 0; actionsSinceLastPlan = 0; insertedAction = false; initGameObjectPos = transform.position; initGameObjectRotY = transform.eulerAngles.y; initLocalRootPos = root.localPosition; lastRootPos = root.position; lastRootRot = root.rotation; }
//////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// // Use this for initialization public void InitializeAgentBrain() { // NAV MESH AGENT TEST GetComponent <NavMeshAgent>().Stop(); GetComponent <NavMeshAgent>().updatePosition = false; GetComponent <NavMeshAgent>().updateRotation = false; locomotionSystem = GetComponent <SoldierLocomotion>(); // initializing neighbor lists neighborObstacles = GetComponent <NeighbourObstacles>(); neighborObstacles.Init(); neighborAgents = GetComponent <NeighbourAgents>(); neighborAgents.Init(); currentState = new State(transform.position); if (GlobalNavigator.usingDynamicNavigationMesh) { currentPolygonIndex = GlobalNavigator.recastSteeringManager.GetClosestPolygon(currentState.getPosition()); } if (goal == null) { Debug.LogError("Goal has not been initialized for this agent"); } goalState = goal.goalState; passableMask = 1; // this could be part of the goal globalPath = new List <State> (); numGlobalPathWaypoints = 0; globalPathPolygonIndices = new List <uint> (); localPaths = new List <List <State> > (); spaceTimePaths = new List <List <State> > (); currentPlanExecutionIndex = 0; offMeshLinkWayPoint = new List <bool>(); taskManager = new TaskManager(); // creating global navigation task globalNavigationTask = new GlobalNavigationtask(currentState, goalState, passableMask, TaskPriority.RealTime, taskManager); globalNavigationTask.taskName = "globalNavigationTask"; // EVENT: AgentBrain is triggered by the globalNavigationTask when GLOBAL_PATH_CHANGED globalNavigationTask.registerObserver(Event.GLOBAL_PATH_CHANGED, this); gridNavigationTasks = new List <GridNavigationTask>(); // creating grid navigation and grid time tasks for each statically allocated global waypoint // -- we can statically allocate how many ever we want for (int i = 0; i < 1; i++) { _addNewEmptyGlobalPathWayPointAtIndex(i); } curves = new AnimationCurve[4]; curves[0] = new AnimationCurve(); // x curves[1] = new AnimationCurve(); // y curves[2] = new AnimationCurve(); // z curves[3] = new AnimationCurve(); // speed }
// Use this for initialization public override void Init(AnimationAnalyzer animAnalyzer, NeighbourAgents neighborhood, NeighbourObstacles obstacles) { analyzer = animAnalyzer; if (analyzer != null && !analyzer.initialized) { analyzer.Init(); } storedPlan = new List <FootstepPlanningAction>(); outputPlan = new Stack <DefaultAction>(); domainList = new List <PlanningDomainBase>(); gpd = new GridPlanningDomain(analyzer); //gtd = new GridTimeDomain(analyzer, obstacles); gtd = new GridTimeDomain(obstacles, neighborhood); fpd = new FootstepPlanningDomain(analyzer, neighborhood, obstacles); if (useGridDomain) { domainList.Add(gpd); //domainList.Add(gpd); } if (useGridTimeDomain) { domainList.Add(gtd); //domainList.Add(gtd); } if (useFootstepDomain) { domainList.Add(fpd); //domainList.Add(fpd); } planner = new BestFirstSearchPlanner(); planner.init(ref domainList, MaxNumberOfNodes); initialized = true; currentState = null; isPlanComputed = false; planChanged = false; goalMeshRenderer = goalStateTransform.gameObject.GetComponent("MeshRenderer") as MeshRenderer; currentGoal = goalStateTransform.position; goalReached = false; }