public void SetNextNode() { if (!pedestrianCharacter) { return; } // Check distant from character to next node if (Vector3.SqrMagnitude(pedestrianCharacter.transform.position - nextNode.transform.position) < DESTINATION_PROXIMITY) // Reached next destination node { if (nextNode == pedestrianEndNode) // Reach the end { if (pedestrianEndNode.destinationReached == DestinationReached.Destroy) { Destroy(pedestrianCharacter); } else if (pedestrianEndNode.destinationReached == DestinationReached.TOBEIMPLEMENTEDTurnBack) { } //TODO: To be implemented else if (pedestrianEndNode.destinationReached == DestinationReached.TOBEIMPLEMENTEDGoToStart) { } //TODO: To be implemented else { //pedestrianControl.target = null; pedestrianCharacter.GetComponent <CharacterDirectionControl>().target = null; } } else { currentNode++; } // Change to next node if (currentNode < pedestrianNodes.Length) { nextNode = pedestrianNodes[currentNode]; } else { nextNode = pedestrianEndNode; } // Set speed to next node's speed; currentSpeed = nextNode.speed; } }
public GameObject SpawnNewPedestrian() { pedestrianCharacter = (GameObject)Instantiate(pedestrianPrefab, pedestrianStartNode.transform.position, Quaternion.identity, this.transform); pedestrianNavMesh = pedestrianCharacter.GetComponent <NavMeshAgent>(); pedestrianControl = pedestrianCharacter.GetComponent <AICharacterControl>(); pedestrianCharacter.gameObject.tag = "Pedestrian"; // Go to the first node if (pedestrianNodes.Length == 0) { nextNode = pedestrianEndNode; } else { nextNode = pedestrianNodes[0]; } currentSpeed = nextNode.speed; return(pedestrianCharacter); }
// Update is called once per frame void Update() { PedestrianDest movingObsEndNode = pedestrianObstacleAgent.GetComponent <PedestrianObsRuoteRL>().agentRoute.activeRoute[11]; movingObsEndNode.transform.localPosition = new Vector3(GetPredictedDestinationX(), 0.5f, -12f); }