private void OnTriggerExit(Collider other) { if (other.CompareTag("Player")) { warnScript.warn = false; onSight = false; objective = currentVertex; } else if (other.CompareTag("GraphNode")) //Para que no se bloquee en un nodo { nodeExitTimer = 0f; } }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("GraphNode")) //llega a un vertice { currentVertex = grafo.getCurrentNode(other.gameObject); grafo.setPlayerNode(currentVertex); } if (other.CompareTag("Exit")) { ganar = true; } }
private void OnTriggerStay(Collider other) { if (other.CompareTag("Player")) { RaycastHit hit; //Cambiar por cono de vista Vector3 direction = (other.transform.position - transform.position).normalized; if (Physics.Raycast(transform.position, direction, out hit, Mathf.Infinity, layerMask)) { if (hit.collider.CompareTag("Player")) { onSight = true; //ve al jugador chasing = false; //chasing se usa si esta siguiendo el grafo localObjective = other.transform.position; pathNodes.Clear(); warnScript.warn = true; /*if(Vector3.Distance(transform.position, other.transform.position) < 8) * { * * }*/ } else { warnScript.warn = false; onSight = false; objective = currentVertex; } } else { warnScript.warn = false; onSight = false; objective = currentVertex; } } if (other.CompareTag("GraphNode")) //Para que no se bloquee en un nodo { nodeExitTimer += Time.deltaTime; if (nodeExitTimer > 2f) { objective = grafo.getRandomNeighbour(currentVertex); } } }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("GraphNode")) //llega a un vertice { //cambiar nodo actual currentVertex = grafo.getCurrentNode(other.gameObject); if (objective == null) { objective = grafo.getRandomNeighbour(currentVertex); } if (currentVertex.index == objective.index) { if (chasing) //hay una lista de nodos { if (pathNodes.Count > 0) { objective = pathNodes[0]; pathNodes.RemoveAt(0); } else { chasing = false; objective = grafo.getRandomNeighbour(currentVertex); } } else { avisado = false;//JORGE!!!!!! objective = grafo.getRandomNeighbour(currentVertex); } //coger siguiente nodo de la lista o aleatorio } } }