// Update is called once per frame new void Update() { //graph.nodes[initial].DrawTriangle(); graph.nodes[end].DrawTriangle(); if (astar_target != null) { int targetNode = graph.GetNearestNodeByCenter(astar_target.transform.position); int characterNode = graph.GetNearestNodeByCenter(character.transform.position); if (targetNode != characterNode && targetNode != end) { if (characterNode != -1) { initial = characterNode; } if (targetNode != -1) { ChangeEndNode(targetNode); } } } character.SetSteering(GetSteering(path), weight, priority); }
// Use this for initialization new void Start() { base.Start(); //Get map graph GameObject map = GameObject.Find("Map Graph"); graph = map.GetComponent <GraphMap>(); initial = graph.GetNearestNodeByCenter(character.transform.position); path = new List <Node>(); if (astar_target != null) { end = graph.GetNearestNodeByCenter(astar_target.transform.position); path = graph.AStar(graph.nodes[initial], graph.nodes[end]); current = path[0].id; path.RemoveAt(0); } }
// Use this for initialization void Start() { //Store waypoints waypoints = new int[3]; pursuerWaypoints = new int[3]; GameObject map = GameObject.Find("Map Graph"); graph = map.GetComponent <GraphMap>(); waypoints[0] = graph.GetNearestNodeByCenter(new Vector3(-116f, 62f, 0f)); waypoints[1] = graph.GetNearestNodeByCenter(new Vector3(-3f, -7f, 0f)); waypoints[2] = graph.GetNearestNodeByCenter(new Vector3(141f, -90f, 0f)); pursuerWaypoints[0] = graph.GetNearestNodeByCenter(new Vector3(-114f, 46f, 0f)); pursuerWaypoints[1] = graph.GetNearestNodeByCenter(new Vector3(5f, 3f, 0f)); pursuerWaypoints[2] = graph.GetNearestNodeByCenter(new Vector3(137f, -77f, 0f)); pursuer = GameObject.Find("Monster_Anger"); calcWaypoint = false; }