void wander() { RaycastHit hit; if (Physics.Raycast(transform.position, transform.forward, out hit, 2) || Physics.Raycast(transform.position, transform.forward + transform.right / 2, out hit, 2) || Physics.Raycast(transform.position, transform.forward - transform.right / 2, out hit, 2) || Physics.Raycast(transform.position, transform.forward + transform.right * 3 / 4, out hit, 2) || Physics.Raycast(transform.position, transform.forward - transform.right * 3 / 4, out hit, 2) ) { if (hit.collider.gameObject.tag == "MovingPlatform") { max_speed = 0; } } else { max_speed = 2; } if (start_node == null && end_node == null) { int random = Random.Range(0, PathGenerator.path_nodes["FrogNode"].Count); start_node = findClosestNode(); end_node = PathGenerator.path_nodes["FrogNode"][random]; m_path = PathGenerator.AlgorithmA(start_node, end_node); } }
public void wander(string tag) { if (start_node == null && end_node == null) { m_path.Clear(); path_index = 0; int random = Random.Range(0, PathGenerator.path_nodes[tag].Count); start_node = findClosestNode(tag); end_node = PathGenerator.path_nodes[tag][random]; m_path = PathGenerator.AlgorithmA(start_node, end_node); } }
public void CreatePath() { if (!has_path) { Debug.Log("start:" + start_node.name); Debug.Log("end: " + end_node.name); m_path = PathGenerator.AlgorithmA(start_node, end_node); has_path = true; } //for (int i = 0; i < m_path.Count - 1; i++) //{ // m_path[i].GetComponent<LineRenderer>().enabled = true; // m_path[i].GetComponent<LineRenderer>().SetPosition(0, m_path[i].transform.position); // m_path[i].GetComponent<LineRenderer>().SetPosition(1, m_path[i + 1].transform.position); //} }
public void hide() { if (!hiddenNodes.Contains(end_node)) { m_path.Clear(); path_index = 0; start_node = null; end_node = null; } if (start_node == null && end_node == null) { SetStartNode(); SetEndNode(); m_path = PathGenerator.AlgorithmA(start_node, end_node); } if (Vector3.Distance(end_node.transform.position, transform.position) < 0.2f) { max_speed = 0; } }
void eat() { if (!m_path.Contains(GameObject.Find("Cheese (1)"))) { m_path.Clear(); path_index = 0; start_node = null; end_node = null; } if (start_node == null && end_node == null) { start_node = findClosestNode("PathNode"); end_node = GameObject.Find("Cheese (1)"); m_path = PathGenerator.AlgorithmA(start_node, end_node); } if (end_node == GameObject.Find("Cheese (1)")) { if (Vector3.Distance(end_node.transform.position, transform.position) < 0.2f) { max_speed = 0; } } }
void GeneratePath() { SetStartNode(); SetEndNode(); path = PathGenerator.AlgorithmA(start_node, end_node); }