// Start is called before the first frame update void Start() { // Get centre position of the environment envCentre = this.transform.parent.transform.position; routeplanAcademy = FindObjectOfType <AcademyPedestrian>(); noOfObstacles = (int)routeplanAcademy.resetParameters["noOfObstacles"]; randomisedObsPos = (int)routeplanAcademy.resetParameters["randomisedObsPos"]; // Get agentRoute from AICharacterBehaviour script agentRoute = this.GetComponent <PedestrianDecisionControl>().agentRoute; noOfRouteNodes = agentRoute.activeRoute.Length - 2; // Exclude endNode & startNode endNode = agentRoute.activeRoute[noOfRouteNodes + 1].transform; startingPosition = this.transform.localPosition; resetEnv = true; _justCalledDone = false; calledDone = false; stackedOutputAction = new float[10]; //for (int i = 0; i < obstacles.Length; i++) //{ // obstacles[i].GetComponent<Obstacle>().isActive = false; // foreach (Transform child in obstacles[i].transform) // child.GetComponent<Renderer>().enabled = false; //} predictedPOC = new GameObject[obstacles.Length]; for (int i = 0; i < obstacles.Length; i++) { if (!POCPrefab) { predictedPOC[i] = new GameObject("Predicted POC" + (i + 1)); } else { predictedPOC[i] = Instantiate(POCPrefab); } predictedPOC[i].AddComponent <Obstacle>(); predictedPOC[i].transform.parent = this.transform.parent; } AgentReset(); }
void OnDrawGizmosSelected() { // Draw a the route path when selected in Unity agentRoute = this.GetComponent <PedestrianDecisionControl>().agentRoute; // Draw the line from agent to direction vector object if exists if (this.GetComponent <PedestrianDecisionControl>().direction != null) { Gizmos.color = Color.red; Gizmos.DrawLine(this.transform.position, this.GetComponent <PedestrianDecisionControl>().direction.transform.position); } // Draw first line from this transform to the target Gizmos.color = Color.white; Gizmos.DrawLine(this.transform.position, agentRoute.activeRoute[0].transform.position); // Draw the path for (int i = 0; i < agentRoute.activeRoute.Length - 1; i++) { Gizmos.DrawLine(agentRoute.activeRoute[i].transform.position, agentRoute.activeRoute[i + 1].transform.position); } }