void Start() { //Debug.Log(" width :" + width + " height:" + height + " diaonal:" + diaonal); //add attractive field followTargetPotential = new PFRadialPotentialField() { type = PF_TYPE.Attract, position = goal.transform.position, potential = MapConfig.diaonal, gradation = 1 }; //add obstacle field obstaclePotential = new PFRadialPotentialField() { type = PF_TYPE.Repell, position = obstacle.transform.position, potential = 100, gradation = 10 }; obstaclePotential_1 = new PFRadialPotentialField() { type = PF_TYPE.Repell, position = obstacle_1.transform.position, potential = 100, gradation = 10 }; obstaclePotential_2 = new PFRadialPotentialField() { type = PF_TYPE.Repell, position = obstacle_2.transform.position, potential = 100, gradation = 10 }; curMap = new PFDynamicPotentialsMap(MapConfig.origin, MapConfig.width, MapConfig.height); curMap.addPotentialField(followTargetPotential); curMap.addPotentialField(obstaclePotential); curMap.addPotentialField(obstaclePotential_1); curMap.addPotentialField(obstaclePotential_2); //set agent and register maps agent = new PFAgent() { position = bot.transform.position }; agent.addDynamicPotentialsMap(curMap); }
void Start() { agentsMap = new PFDynamicPotentialsMap(MapConfig.origin, MapConfig.width, MapConfig.height); agentsMap.addPotentialField(Performance.current.goalField); for (int i = 0; i < Performance.current.agents.Count; i++) { if (Performance.current.agents[i].curAgent != this.curAgent) { agentsMap.addPotentialField(Performance.current.agents[i].curAgent); } } curAgent.addStaticPotentialsMap(Performance.current.obstaclesPotentialsMap); curAgent.addDynamicPotentialsMap(agentsMap); }
// Use this for initialization void Start() { //create static map obstaclesPotentialsMap = new PFStaticPotentialsMap(MapConfig.origin, MapConfig.width, MapConfig.height); obstacleFields = new PFPotentialField[obstacles.Length]; for (int i = 0; i < obstacleFields.Length; i++) { obstacleFields[i] = new PFRadialPotentialField() { type = PF_TYPE.Repell, position = obstacles[i].position, potential = 100, gradation = 10 }; obstaclesPotentialsMap.addPotentialField(obstacleFields[i]); } goalField = new PFRadialPotentialField() { type = PF_TYPE.Attract, position = goal.position, potential = MapConfig.width + MapConfig.height, gradation = 1 }; agent1 = new PFAgent() { type = PF_TYPE.Repell, position = agent1_tran.position, potential = 4, gradation = 1 }; agent2 = new PFAgent() { type = PF_TYPE.Repell, position = agent2_tran.position, potential = 4, gradation = 1 }; agent1_tran.gameObject.GetComponent<BaseControl_2>().agent = agent1; agent1_tran.gameObject.GetComponent<BaseControl_2>().neighbour_agent = agent2; agent2_tran.gameObject.GetComponent<BaseControl_2>().agent = agent2; agent2_tran.gameObject.GetComponent<BaseControl_2>().neighbour_agent = agent1; agent1Mp = new PFDynamicPotentialsMap(MapConfig.origin, MapConfig.width, MapConfig.height); agent1Mp.addPotentialField(goalField); agent1Mp.addPotentialField(agent2); agent2Mp = new PFDynamicPotentialsMap(MapConfig.origin, MapConfig.width, MapConfig.height); agent2Mp.addPotentialField(goalField); agent2Mp.addPotentialField(agent1); agent1.addStaticPotentialsMap(obstaclesPotentialsMap); agent1.addDynamicPotentialsMap(agent1Mp); agent2.addStaticPotentialsMap(obstaclesPotentialsMap); agent2.addDynamicPotentialsMap(agent2Mp); }
// Use this for initialization void Start() { //create static map obstaclesPotentialsMap = new PFStaticPotentialsMap(MapConfig.origin, MapConfig.width, MapConfig.height); obstacleFields = new PFPotentialField[obstacles.Length]; for (int i = 0; i < obstacleFields.Length; i++) { obstacleFields[i] = new PFRadialPotentialField() { type = PF_TYPE.Repell, position = obstacles[i].position, potential = 100, gradation = 10 }; obstaclesPotentialsMap.addPotentialField(obstacleFields[i]); } goalField = new PFRadialPotentialField() { type = PF_TYPE.Attract, position = goal.position, potential = MapConfig.width + MapConfig.height, gradation = 1 }; agent1 = new PFAgent() { type = PF_TYPE.Repell, position = agent1_tran.position, potential = 4, gradation = 1 }; agent2 = new PFAgent() { type = PF_TYPE.Repell, position = agent2_tran.position, potential = 4, gradation = 1 }; agent1_tran.gameObject.GetComponent <BaseControl_2>().agent = agent1; agent1_tran.gameObject.GetComponent <BaseControl_2>().neighbour_agent = agent2; agent2_tran.gameObject.GetComponent <BaseControl_2>().agent = agent2; agent2_tran.gameObject.GetComponent <BaseControl_2>().neighbour_agent = agent1; agent1Mp = new PFDynamicPotentialsMap(MapConfig.origin, MapConfig.width, MapConfig.height); agent1Mp.addPotentialField(goalField); agent1Mp.addPotentialField(agent2); agent2Mp = new PFDynamicPotentialsMap(MapConfig.origin, MapConfig.width, MapConfig.height); agent2Mp.addPotentialField(goalField); agent2Mp.addPotentialField(agent1); agent1.addStaticPotentialsMap(obstaclesPotentialsMap); agent1.addDynamicPotentialsMap(agent1Mp); agent2.addStaticPotentialsMap(obstaclesPotentialsMap); agent2.addDynamicPotentialsMap(agent2Mp); }
void Start() { //Debug.Log(" width :" + width + " height:" + height + " diaonal:" + diaonal); //add attractive field followTargetPotential = new PFRadialPotentialField() { type = PF_TYPE.Attract, position = goal.transform.position, potential = MapConfig.diaonal, gradation = 1 }; //add obstacle field obstaclePotential = new PFRadialPotentialField() { type = PF_TYPE.Repell, position = obstacle.transform.position, potential = 100, gradation = 10 }; obstaclePotential_1 = new PFRadialPotentialField() { type = PF_TYPE.Repell, position = obstacle_1.transform.position, potential = 100, gradation = 10 }; obstaclePotential_2 = new PFRadialPotentialField() { type = PF_TYPE.Repell, position = obstacle_2.transform.position, potential = 100, gradation = 10 }; curMap = new PFDynamicPotentialsMap(MapConfig.origin, MapConfig.width, MapConfig.height); curMap.addPotentialField(followTargetPotential); curMap.addPotentialField(obstaclePotential); curMap.addPotentialField(obstaclePotential_1); curMap.addPotentialField(obstaclePotential_2); //set agent and register maps agent = new PFAgent(){ position = bot.transform.position }; agent.addDynamicPotentialsMap(curMap); }