public bool SetPath(NavMeshPath path){}
// Use this for initialization void Start() { _navMeshAgent = gameObject.GetComponent <NavMeshAgent>(); _path = new NavMeshPath(); }
//This will show in Unity name of waypoints and flags private void OnSceneGUI() { //Casting (Unity reference documentation) AIWaypointNetwork network = (AIWaypointNetwork)target; //Looping through waypoints for (int i = 0; i < network.waypoints.Count; i++) { //Skip waypoint that is null if (network.waypoints[i] != null) { //Label needs 2 parameters - Vector and sttring Handles.Label(network.waypoints[i].position, "Waypoint " + i.ToString()); } } if (network.DisplayMode == PathDisplayMode.Connections) { //DrawPolyLine - takes Array of Vector3 points //We pass numbers of waypoints + 1 because last will be duplicate of first waypoint //(network.waypoints.Count + 1) //and that will add aditional line to connect everything Vector3[] linePoints = new Vector3[network.waypoints.Count + 1]; for (int i = 0; i < network.waypoints.Count; i++) { // when i = 6 (the num,ber of waypoints) is not valid because in the Array we have //from 0 to 5, so when i = 6 we want that to be the first index (0,1,2,3,4,5,1) int index = i != network.waypoints.Count ? i : 0; if (network.waypoints[index] != null) { //If it is not null reference we will get index in linePoints linePoints[i] = network.waypoints[index].position; } else { //If it is null this code will make sure that the lines will go to //infinity and wee will be abale to see that graphicaly linePoints[i] = new Vector3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity); } //Lines colour Handles.color = Color.cyan; //This will draw the lines between waypoints Handles.DrawPolyLine(linePoints); } } else { if (network.DisplayMode == PathDisplayMode.Paths) { //For this to work we need using UnityEngine.AI; NavMeshPath path = new NavMeshPath(); //We will only use this code if UIStart and UIEnd is not null if (network.waypoints[network.UIStart] != null && network.waypoints[network.UIEnd] != null) { //We take positions of waypionts to create start path for AI Vector3 from = network.waypoints[network.UIStart].position; //We take positions of waypionts to create end path for AI Vector3 to = network.waypoints[network.UIEnd].position; //Calculates path from waypoints, it takes vector,vector,mask, NavMesh reference NavMesh.CalculatePath(from, to, NavMesh.AllAreas, path); //Takes corners for ploting paths Handles.color = Color.yellow; Handles.DrawPolyLine(path.corners); } } } }
// Start is called before the first frame update void Start() { path = new NavMeshPath(); GameObject cube1 = GameObject.Find("Cube (1)"); GameObject cube2 = GameObject.Find("Cube (2)"); GameObject cube3 = GameObject.Find("Cube (3)"); GameObject cube4 = GameObject.Find("Cube (4)"); GameObject cube5 = GameObject.Find("Cube (5)"); GameObject target1 = GameObject.Find("Target"); GameObject target2 = GameObject.Find("Target (1)"); GameObject target3 = GameObject.Find("Target (2)"); GameObject target4 = GameObject.Find("Target (3)"); GameObject target5 = GameObject.Find("Target (4)"); ShowPath showpath1 = cube1.GetComponent <ShowPath>(); ShowPath showpath2 = cube2.GetComponent <ShowPath>(); ShowPath showpath3 = cube3.GetComponent <ShowPath>(); ShowPath showpath4 = cube4.GetComponent <ShowPath>(); NavMesh.CalculatePath(cube1.transform.position, target1.transform.position, NavMesh.AllAreas, path); float distance = 0; for (int i = 0; i < path.corners.Length - 1; i++) { distance += Vector3.Distance(path.corners[i], path.corners[i + 1]); } evacuationTime1.Add(distance); NavMesh.CalculatePath(cube1.transform.position, target2.transform.position, NavMesh.AllAreas, path); distance = 0; for (int i = 0; i < path.corners.Length - 1; i++) { distance += Vector3.Distance(path.corners[i], path.corners[i + 1]); } evacuationTime1.Add(distance); NavMesh.CalculatePath(cube1.transform.position, target3.transform.position, NavMesh.AllAreas, path); distance = 0; for (int i = 0; i < path.corners.Length - 1; i++) { distance += Vector3.Distance(path.corners[i], path.corners[i + 1]); } evacuationTime1.Add(distance); NavMesh.CalculatePath(cube1.transform.position, target4.transform.position, NavMesh.AllAreas, path); distance = 0; for (int i = 0; i < path.corners.Length - 1; i++) { distance += Vector3.Distance(path.corners[i], path.corners[i + 1]); } evacuationTime1.Add(distance); NavMesh.CalculatePath(cube1.transform.position, target5.transform.position, NavMesh.AllAreas, path); distance = 0; for (int i = 0; i < path.corners.Length - 1; i++) { distance += Vector3.Distance(path.corners[i], path.corners[i + 1]); } evacuationTime1.Add(distance); NavMesh.CalculatePath(cube2.transform.position, target1.transform.position, NavMesh.AllAreas, path); distance = 0; for (int i = 0; i < path.corners.Length - 1; i++) { distance += Vector3.Distance(path.corners[i], path.corners[i + 1]); } evacuationTime2.Add(distance); NavMesh.CalculatePath(cube2.transform.position, target2.transform.position, NavMesh.AllAreas, path); distance = 0; for (int i = 0; i < path.corners.Length - 1; i++) { distance += Vector3.Distance(path.corners[i], path.corners[i + 1]); } evacuationTime2.Add(distance); NavMesh.CalculatePath(cube2.transform.position, target3.transform.position, NavMesh.AllAreas, path); distance = 0; for (int i = 0; i < path.corners.Length - 1; i++) { distance += Vector3.Distance(path.corners[i], path.corners[i + 1]); } evacuationTime2.Add(distance); NavMesh.CalculatePath(cube2.transform.position, target4.transform.position, NavMesh.AllAreas, path); distance = 0; for (int i = 0; i < path.corners.Length - 1; i++) { distance += Vector3.Distance(path.corners[i], path.corners[i + 1]); } evacuationTime2.Add(distance); NavMesh.CalculatePath(cube2.transform.position, target5.transform.position, NavMesh.AllAreas, path); distance = 0; for (int i = 0; i < path.corners.Length - 1; i++) { distance += Vector3.Distance(path.corners[i], path.corners[i + 1]); } evacuationTime2.Add(distance); NavMesh.CalculatePath(cube3.transform.position, target1.transform.position, NavMesh.AllAreas, path); distance = 0; for (int i = 0; i < path.corners.Length - 1; i++) { distance += Vector3.Distance(path.corners[i], path.corners[i + 1]); } evacuationTime3.Add(distance); NavMesh.CalculatePath(cube3.transform.position, target2.transform.position, NavMesh.AllAreas, path); distance = 0; for (int i = 0; i < path.corners.Length - 1; i++) { distance += Vector3.Distance(path.corners[i], path.corners[i + 1]); } evacuationTime3.Add(distance); NavMesh.CalculatePath(cube3.transform.position, target3.transform.position, NavMesh.AllAreas, path); distance = 0; for (int i = 0; i < path.corners.Length - 1; i++) { distance += Vector3.Distance(path.corners[i], path.corners[i + 1]); } evacuationTime3.Add(distance); NavMesh.CalculatePath(cube3.transform.position, target4.transform.position, NavMesh.AllAreas, path); distance = 0; for (int i = 0; i < path.corners.Length - 1; i++) { distance += Vector3.Distance(path.corners[i], path.corners[i + 1]); } evacuationTime3.Add(distance); NavMesh.CalculatePath(cube3.transform.position, target5.transform.position, NavMesh.AllAreas, path); distance = 0; for (int i = 0; i < path.corners.Length - 1; i++) { distance += Vector3.Distance(path.corners[i], path.corners[i + 1]); } evacuationTime3.Add(distance); NavMesh.CalculatePath(cube4.transform.position, target1.transform.position, NavMesh.AllAreas, path); distance = 0; for (int i = 0; i < path.corners.Length - 1; i++) { distance += Vector3.Distance(path.corners[i], path.corners[i + 1]); } evacuationTime4.Add(distance); NavMesh.CalculatePath(cube4.transform.position, target2.transform.position, NavMesh.AllAreas, path); distance = 0; for (int i = 0; i < path.corners.Length - 1; i++) { distance += Vector3.Distance(path.corners[i], path.corners[i + 1]); } evacuationTime4.Add(distance); NavMesh.CalculatePath(cube4.transform.position, target3.transform.position, NavMesh.AllAreas, path); distance = 0; for (int i = 0; i < path.corners.Length - 1; i++) { distance += Vector3.Distance(path.corners[i], path.corners[i + 1]); } evacuationTime4.Add(distance); NavMesh.CalculatePath(cube4.transform.position, target4.transform.position, NavMesh.AllAreas, path); distance = 0; for (int i = 0; i < path.corners.Length - 1; i++) { distance += Vector3.Distance(path.corners[i], path.corners[i + 1]); } evacuationTime4.Add(distance); NavMesh.CalculatePath(cube4.transform.position, target5.transform.position, NavMesh.AllAreas, path); distance = 0; for (int i = 0; i < path.corners.Length - 1; i++) { distance += Vector3.Distance(path.corners[i], path.corners[i + 1]); } evacuationTime4.Add(distance); evacuationTime5.Add(Vector3.Distance(target1.transform.position, cube5.transform.position)); evacuationTime5.Add(Vector3.Distance(target2.transform.position, cube5.transform.position)); evacuationTime5.Add(Vector3.Distance(target3.transform.position, cube5.transform.position)); evacuationTime5.Add(Vector3.Distance(target4.transform.position, cube5.transform.position)); evacuationTime5.Add(Vector3.Distance(target5.transform.position, cube5.transform.position)); }
void Update() { SetAgentPosition(); if (Input.GetMouseButtonDown(0) && !Input.GetKey(KeyCode.LeftShift)) { var ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray.origin, ray.direction, out m_HitInfo)) { //m_Agent.destination = m_HitInfo.point; m_Path = new NavMeshPath(); endDestination = m_HitInfo.point; m_Agent.CalculatePath(endDestination, m_Path); pathIter = 1; m_Agent.isStopped = false; } } if (m_Path.corners == null || m_Path.corners.Length == 0) { return; } if (pathIter >= m_Path.corners.Length) { destination = new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); m_Agent.isStopped = true; return; } else { destination = m_Path.corners[pathIter]; } if (destination.x < float.PositiveInfinity) { Vector3 direction = destination - AgentPosition; var newDir = Vector3.RotateTowards(transform.forward, direction, 50 * Time.deltaTime, 0.0f); var newRot = Quaternion.LookRotation(newDir); transform.rotation = Quaternion.Slerp(transform.rotation, newRot, Time.deltaTime * 2f); float distance = Vector3.Distance(AgentPosition, destination); if (distance > m_Agent.radius + 0.1) { Vector3 movement = transform.forward * Time.deltaTime * 2f; m_Agent.Move(movement); } else { ++pathIter; if (pathIter >= m_Path.corners.Length) { destination = new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); m_Agent.isStopped = true; } } } }
private static bool CalculatePathInternal(Vector3 sourcePosition, Vector3 targetPosition, int passableMask, NavMeshPath path){}
void Update() { SetAgentPosition(); if (isPatrolling) { Wander(); //RandomNavSphere(transform.position, range); } if (shipTarget == null) { isPatrolling = true; } currentTimer += 1 * Time.deltaTime; if (health.isDead == false) { if (currentTimer >= maxTimer) { if (shipTarget != null) { m_Agent.destination = shipTarget.position; m_Path = new NavMeshPath(); m_Agent.CalculatePath(shipTarget.position, m_Path); pathIter = 1; m_Agent.isStopped = false; currentTimer = 0; } } } if (m_Path.corners == null || m_Path.corners.Length == 0) { return; } if (pathIter >= m_Path.corners.Length) { if (!health.isDead) { destination = new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); m_Agent.isStopped = true; return; } } else { destination = m_Path.corners[pathIter]; } if (destination.x < float.PositiveInfinity) { Vector3 direction = destination - AgentPosition; var newDir = Vector3.RotateTowards(transform.forward, direction, 50 * Time.deltaTime, 0.0f); var newRot = Quaternion.LookRotation(newDir); transform.rotation = Quaternion.Slerp(transform.rotation, newRot, Time.deltaTime * SPEED); float distance = Vector3.Distance(AgentPosition, destination); if (distance > m_Agent.radius + 0.1) { Vector3 movement = transform.forward * Time.deltaTime * SPEED; if (!health.isDead) { m_Agent.Move(movement); } } else { ++pathIter; if (pathIter >= m_Path.corners.Length) { destination = new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); m_Agent.isStopped = true; //IF WANDERING hasSetWaypoint = false; } } } }
public void FindPath() { Vector3 targetVec; //Vector3 newDir; Vector3 newPos; //bool still = false; switch (this.currentBehaviour) { case Behaviour.Patrolling: currentWayPoint = wayPoints[wayPointI].transform; if ((int)this.transform.position.x == (int)currentWayPoint.position.x && (int)this.transform.position.z == (int)currentWayPoint.position.z) { wayPointI++; //currentWayPoint = wayPoints [wayPointI].transform; } if (wayPointI >= wayPoints.Length) { wayPointI = 0; } agent.SetDestination(currentWayPoint.position); /*targetVec = currentWayPoint.position - this.transform.position; * newDir = Vector3.RotateTowards(transform.forward, targetVec, rotSpeed*Time.deltaTime, 0.0f); * newPos = Vector3.MoveTowards( this.transform.position, currentWayPoint.position, this.movementSpeed * Time.deltaTime );*/ break; case Behaviour.SeeingPlayer: if (!setPath) { agent.SetDestination(lastPlayerPos); setPath = true; } else { NavMeshPath path = new NavMeshPath(); agent.CalculatePath(lastPlayerPos, path); agent.SetPath(path); } /*targetVec = lastPlayerPos - this.transform.position; * newDir = Vector3.RotateTowards(transform.forward, targetVec, rotSpeed*Time.deltaTime, 0.0f); * newPos = Vector3.MoveTowards( this.transform.position, lastPlayerPos, this.movementSpeed * Time.deltaTime );*/ break; case Behaviour.CheckingLastPlayerPos: if ((int)this.transform.position.x == (int)lastPlayerPos.x && (int)this.transform.position.z == (int)lastPlayerPos.z) { currentBehaviour = Behaviour.IMapNavigating; } if (!setPath) { agent.SetDestination(lastPlayerPos); setPath = true; } else { NavMeshPath path = new NavMeshPath(); agent.CalculatePath(lastPlayerPos, path); agent.SetPath(path); } //targetVec = lastPlayerPos - this.transform.position; //newDir = Vector3.RotateTowards(transform.forward, targetVec, rotSpeed*Time.deltaTime, 0.0f); //newPos = Vector3.MoveTowards( this.transform.position, lastPlayerPos, this.movementSpeed * Time.deltaTime ); break; case Behaviour.IMapNavigating: int max = 0; int current = 0; int x, y = 0; Vector3 IMapPos = Vector3.zero; //Check 5x5 grid around agent in influencemap to get largets value from map int squareSize = 21; //must be odd for (int i = 0; i < squareSize; i++) { for (int j = 0; j < squareSize; j++) { x = ((((int)this.transform.position.x) - influenceMapOffsetX) / influenceMapScale); y = ((((int)this.transform.position.z) - influenceMapOffsetY) / influenceMapScale); current = this.influenceMap[y - ((squareSize - 1) / 2) + i][x - ((squareSize - 1) / 2) + j]; if (current > max) { max = current; Vector3 newVec = new Vector3(i - ((squareSize - 1) / 2), this.transform.position.y, j - ((squareSize - 1) / 2)); newVec.Normalize(); IMapPos = this.transform.position + newVec * IMapScale; } } } //Debug.Log ("value " + this.influenceMap [y] [x]); if (max == 0) { this.currentBehaviour = Behaviour.Patrolling; } if (!setPath) { agent.SetDestination(IMapPos); setPath = true; } else { NavMeshPath path = new NavMeshPath(); agent.CalculatePath(IMapPos, path); agent.SetPath(path); } break; case Behaviour.Still: targetVec = currentWayPoint.position - this.transform.position; //newDir = Vector3.RotateTowards(transform.forward, targetVec, rotSpeed * Time.deltaTime, 0.0f); newPos = this.transform.position; //still = true; break; default: Debug.Log("Default!"); currentWayPoint = wayPoints[wayPointI].transform; if ((int)this.transform.position.x == (int)currentWayPoint.position.x && (int)this.transform.position.z == (int)currentWayPoint.position.z) { wayPointI++; } if (wayPointI >= wayPoints.Length) { wayPointI = 0; } targetVec = currentWayPoint.position - this.transform.position; //newDir = Vector3.RotateTowards(transform.forward, targetVec, rotSpeed * Time.deltaTime, 0.0f); newPos = Vector3.MoveTowards(this.transform.position, currentWayPoint.position, this.movementSpeed * Time.deltaTime); break; } //if (!still) //this.transform.Translate(movementSpeed*Vector3.forward*Time.deltaTime); //this.transform.position = new Vector3(newPos.x, 0.5f, newPos.z); //this.transform.rotation = Quaternion.LookRotation(newDir); }
//public GameObject DEBUGPathNodePrefab;// Use to visualize path // Use this for initialization void Start() { m_path = new NavMeshPath(); }
protected void Awake() { brain = GetComponent <AIBrain>(); agent = GetComponent <NavMeshAgent>(); path = new NavMeshPath(); }
void Runaway() { target = waypoints[waypointInd]; path = new NavMeshPath(); agent.CalculatePath(target.transform.position, path); //chaseSpeed = 3; //agent.speed = chaseSpeed; //agent.isStopped = true; agent.SetPath(path); agent.speed = patrolSpeed; path = new NavMeshPath(); //path = new NavMeshPath(); //agent.CalculatePath(waypoints[waypointInd].transform.position, path); //chaseSpeed = 3; //agent.speed = chaseSpeed; //agent.isStopped = true; //agent.SetPath(path); if (pathpending) { agent.Move(agent.desiredVelocity * Time.deltaTime); } if (!pathpending) { agent.isStopped = false; agent.Move(agent.desiredVelocity * Time.deltaTime); } if (Vector3.Distance(transform.position, player.transform.position) < 20) { StartCoroutine(Flee()); } if (Vector3.Distance(transform.position, waypoints[waypointInd].transform.position) >= 3) { agent.SetDestination(waypoints[waypointInd].transform.position); if (pathpending) { agent.Move(agent.desiredVelocity * Time.deltaTime); } if (!pathpending) { agent.isStopped = false; agent.Move(agent.desiredVelocity * Time.deltaTime); } //agent.CalculatePath(waypoints[waypointInd].transform.position, path); //agent.SetPath(path); agent.SetDestination(waypoints[waypointInd].transform.position); agent.Move(agent.desiredVelocity * Time.deltaTime); //character.Move(agent.desiredVelocity, false, false); } if (Vector3.Distance(transform.position, waypoints[waypointInd].transform.position) <= 3) { //agent.destination = (waypoints[waypointInd+1].transform.position); //agent.Move(agent.desiredVelocity * Time.deltaTime); //character.Move(Vector3.zero, false, false); //print("Boss choosing new navpoint"); if (!randomize) { waypointInd = waypointInd += 1; if (waypointInd >= waypoints.Length) { waypointInd = 0; } } if (randomize) { waypointInd = Random.Range(0, waypoints.Length); } //Patrol(); agent.SetDestination(waypoints[waypointInd].transform.position); //agent.CalculatePath(waypoints[waypointInd].transform.position, path); //agent.SetPath(path); agent.Move(agent.desiredVelocity * Time.deltaTime); //character.Move(agent.desiredVelocity, false, false); } }
// Update is called once per frame void Update() { // Si el pato no está siguiendo al jugador if (!GameObject.FindGameObjectWithTag("DuckSpawner").GetComponent <DuckGenerator>().followPlayer) { // Si no están siguiendo al jugador, usarán su velocidad habitual _agent.speed = speed; // Definimos la distancia a la que se detendrán del objetivo _agent.stoppingDistance = 0.2f; // Pasamos la velociadad al parámetro del Animator para que cumpla la transición de paso a andar anim.SetFloat("speed", speed); // Si se está reproduciendo Idle, aumentamos el contador if (startCounter) { counter += Time.deltaTime; } // Al terminar de reproducir la animación de Idle, el pato caminará a un nuevo destino if (counter >= idleTime) { counter = 0f; startCounter = false; anim.SetFloat("speed", speed); currentDestiny = DuckGenerator.posicionAleatoriaEnRadio(); _agent.SetDestination(currentDestiny); } // Reducimos la velocidad del parámetro del animator cuando consideramos que está en el objetivo, activando el cronómetro y reproduciendo la animación de Idle if (_agent.remainingDistance <= _agent.stoppingDistance) { anim.SetFloat("speed", 0f); startCounter = true; } } // Si está siguiendo al jugador else { // Reseteamos el contador startCounter = false; counter = 0f; // Los patos tendrán el doble de la velocidad del jugador _agent.speed = 3.5f; // Los patos se detendrán cuando estén a esta distancia de su objetivo _agent.stoppingDistance = 0.2f; // Variable que comprobará que el destino del agente es válido bool stopIfUnreachable = false; // Cuando el jugador avance if (_agent.destination != currentDestiny) { // Comprobamos si el camino es viable NavMeshPath path = new NavMeshPath(); _agent.CalculatePath(currentDestiny, path); if (path.status == NavMeshPathStatus.PathInvalid || path.status == NavMeshPathStatus.PathPartial) { // Si no lo es, comprobaremos que se hace en el DuckGenerator stopIfUnreachable = true; returnToSpawn = true; } else { // Si lo es, ponemos el destino actual y cambiamos la avariable de retorno _agent.SetDestination(currentDestiny); returnToSpawn = false; } } // Cuando el jugador esté quieto, se reproducirá la animación de salto mientras miran hacia él, siempre que estén en una posición válida if (Vector3.Distance(_agent.destination, transform.position) <= _agent.stoppingDistance || stopIfUnreachable) { Quaternion targetRotation = Quaternion.LookRotation(player.transform.position - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, rotSpeed * Time.deltaTime); anim.SetBool("jump", true); } // Cuando el jugador se encuentre en posición lo seguirán else { anim.SetBool("jump", false); anim.SetFloat("speed", 1f); } } }
private void InitializeCustomer(int newId) { actionTimer = Random.Range(0f, 2f); atDestination = false; customerId = newId; currentState = CustomerState.ENTER; happiness = 80; happinessLossRate = Random.Range(4f, 8f); isWaiting = false; waitingTimer = 0f; waitingMaximum = Random.Range(5f, 10f); pathTries = 0; path = new NavMeshPath(); int remainder = 100; int random = 0; switch (customerId) { // 0 - Sweet, 1 - Sour, 2 - Salty, 3 - Bitter.In Percent. case 0: // Standard Blue: salty, bitter, sour customerName = "Blue"; random = Random.Range(40, 71); remainder -= random; customerPreference[2] = random; random = Random.Range(Mathf.CeilToInt(0.5f * remainder), remainder + 1); remainder -= random; customerPreference[3] = random; customerPreference[1] = remainder; break; case 1: // Standard Green: sour, bitter, salty customerName = "Green"; random = Random.Range(40, 71); remainder -= random; customerPreference[1] = random; random = Random.Range(Mathf.CeilToInt(0.5f * remainder), remainder + 1); remainder -= random; customerPreference[3] = random; customerPreference[2] = remainder; break; case 2: // Standard Orange: sweet, sour customerName = "Orange"; random = Random.Range(40, 51); remainder -= random; customerPreference[0] = random; random = Random.Range(40, 51); remainder -= random; customerPreference[1] = random; customerPreference[Random.Range(2, 4)] = remainder; break; case 3: // Sim (Random distribution) customerName = "Sims"; for (int i = 0; i < 3; i++) { random = Random.Range(0, remainder + 1); remainder -= random; customerPreference[i] = random; } customerPreference[3] = remainder; for (int i = 0; i < 3; i++) { int index = Random.Range(0, i); if (index != i) { int temp = customerPreference[i]; customerPreference[i] = customerPreference[index]; customerPreference[index] = temp; } } break; case 4: // Angel (Sweet) customerName = "Angel"; happinessLossRate = Random.Range(2f, 4f); random = Random.Range(50, 101); remainder -= random; customerPreference[0] = random; random = Mathf.FloorToInt(remainder / 3); remainder -= random; customerPreference[1] = random; random = Mathf.FloorToInt(remainder / 3); remainder -= random; customerPreference[3] = random; customerPreference[2] = remainder; break; case 5: // Devil (bitter, sour) customerName = "Devil"; happinessLossRate = Random.Range(8f, 10f); random = Random.Range(40, 51); remainder -= random; customerPreference[3] = random; random = Random.Range(40, 51); remainder -= random; customerPreference[1] = random; customerPreference[Random.Range(2, 4)] = remainder; break; case 6: // Style (neutral) customerName = "Style"; for (int i = 0; i < 4; i++) { customerPreference[i] = 25; } break; default: Debug.Log("No valid Customer ID"); break; } }
/// <summary> /// Start is called before the first frame and gets all the needed /// components from the puppet, its children and the scene. /// </summary> void Start() { // Find the master battle script component. Return an error if it is // not found. masterBattleScript = GameObject.Find(MASTER_BATTLE_LOOP). GetComponent <MasterBattleScript>(); if (masterBattleScript == null) { Debug.LogError("Master Battle Script could not be found!"); } // Find the destination indicator. Return and error if it is not found, // otherwise, un-child it and disable it. destinationIndicator = transform.Find(DESTINATION_INDICATOR).gameObject; if (destinationIndicator == null) { Debug.LogError("The Destination Object could not be found in " + gameObject.name); } else { destinationIndicator.transform.parent = null; enableDestinationIndicator(false); } // Find the nav mesh agent and remove updated rotation. navMeshAgent = GetComponent <NavMeshAgent>(); navMeshAgent.updateRotation = false; // Create a new mesh path for the passive path line to calcualte the // predicted movement of the puppet. path = new NavMeshPath(); // Find the line renderer and set its width and position count. pathLineRenderer = GetComponent <LineRenderer>(); pathLineRenderer.startWidth = linePathWidth; pathLineRenderer.endWidth = pathLineRenderer.startWidth; pathLineRenderer.positionCount = 0; // Find the selected indicator. If it cannot be found, throw an error, // otherwise, diable it. selectedIndicator = transform.Find(SELECTED_INDICATOR).gameObject; if (selectedIndicator == null) { Debug.LogError("The selected indicator could not be found in " + gameObject.name); } else { enableSelectedIndicator(false); } // Find the main player camera. If it couldnt be found, throw an error. player = Camera.main.gameObject; if (player == null) { Debug.LogError("There is no main camera!"); } // Initialize battle actions battleActions = new List <BattleAction>(); // Add punch as basic action all hunters have (if they have a weapon we // could add a system where it removes the punch but for now it is // on all hunters). !!REMEMBER TO DO ANYTHING RELATED TO THE CONNECTED // HUNTER IN THE SET HUNTER FUNCTION!! battleActions.Add(Punch.getAction()); battleActions.Add(DoublePunch.getAction()); // Finally, set modifiers to 0 maxSanityModifier = 0; meleeAttackCountModifier = 0; actionPointCountModifier = 0; actionRefillModifier = 0; toughnessModifier = 0; strengthModifier = 0; movementModifier = 0; }
public bool CalculatePath(Vector3 targetPosition, NavMeshPath path){}
/* * * 234/235/236 zusammen als 234 * 306/308/324/325/327/328/329/345/346/348 zusammen als 306 * 304 Mensa * 700/720 zusammen als 700 * */ private IEnumerator Spawn() { _studentList = CommuteController.CommuteControllerInstance.GetStudentList(); int studentListSize = _studentList.Length; while (true) { int gameTime = (int)ClockManagement.ClockManagementInstance.GetTime(); GameObject instantiatedAgent = null; GameObject instantiatedLine = null; foreach (Student student in _studentList) { if (student.check(gameTime) == 1) { GameObject startDoor; GameObject endDoor; string[] routePoints = student.RoutePoints(); if (routePoints[0] == routePoints[1]) { continue; } if (routePoints[0] == "Spawn") { startDoor = GameObject.Find("SpawnPoint (" + student.GetSpawnID() + ")"); } else { startDoor = FindDoor(routePoints[0]); } if (routePoints[1] == "Spawn") { endDoor = GameObject.Find("SpawnPoint (" + student.GetSpawnID() + ")"); } else { endDoor = FindDoor(routePoints[1]); } Vector3 spawnPoint = UnityEngine.Random.insideUnitSphere * 30f + startDoor.transform.position; NavMeshHit hit; NavMesh.SamplePosition(spawnPoint, out hit, 30f, 1); spawnPoint = hit.position; spawnPoint.y = 1; instantiatedAgent = (GameObject)Instantiate(agent, spawnPoint, transform.rotation); int startIndex = NameToIndex(startDoor.name); int endIndex = NameToIndex(endDoor.name); NavMeshPath path = _pathList[startIndex, endIndex]; instantiatedAgent.GetComponent <NavMeshAgentMovement>().SetPersonality(new float[] { student.GetSpeed(), 0.04f, 4f }); instantiatedAgent.GetComponent <NavMeshAgentMovement>().SetPath(path.corners); if (!alreadyUsedPaths.ContainsValue(path)) { instantiatedLine = (GameObject)Instantiate(lineObject); instantiatedLine.GetComponent <DrawPath>().DrawPathOnFloor(path.corners); alreadyUsedPaths.Add(pathID, path); instantiatedLineList.Add(pathID, instantiatedLine); pathID++; } else { foreach (var pair in alreadyUsedPaths) { if (pair.Value == path) { instantiatedLineList[pair.Key].GetComponent <DrawPath>().ChangeWidthOfLine(); } } } } } yield return(new WaitForSeconds(3f)); } }
private static bool INTERNAL_CALL_CalculatePathInternal(NavMeshAgent self, ref Vector3 targetPosition, NavMeshPath path){}
void Start() { navMeshAgent = GetComponent <NavMeshAgent>(); path = new NavMeshPath(); }
///<summary> /// Make the agent move on the given path. ///</summary> /// <param name="path">The path which the agent should now take</param> private void setPath(NavMeshPath path) { navMeshAgent.SetPath(path); }
private static void CreateList( AgentActor agent, List <ActionPoint> source, List <ActionPoint> destination, EventType eventType, bool isFollow, bool isRain) { Manager.Map instance = Singleton <Manager.Map> .Instance; int searchCount = Singleton <Manager.Map> .Instance.EnvironmentProfile.SearchCount; float meshSampleDistance = Singleton <Resources> .Instance.LocomotionProfile.ActionPointNavMeshSampleDistance; Dictionary <int, bool> toRelease = DictionaryPool <int, bool> .Get(); foreach (ActionPoint actionPoint1 in source) { if (!Object.op_Equality((Object)actionPoint1, (Object)null) && !Object.op_Equality((Object)actionPoint1.OwnerArea, (Object)null) && (actionPoint1.IsNeutralCommand && !actionPoint1.IsReserved(agent))) { List <ActionPoint> connectedActionPoints = actionPoint1.ConnectedActionPoints; if (!connectedActionPoints.IsNullOrEmpty <ActionPoint>()) { bool flag = false; foreach (ActionPoint actionPoint2 in connectedActionPoints) { if (!Object.op_Equality((Object)actionPoint2, (Object)null) && (!actionPoint2.IsNeutralCommand || actionPoint2.IsReserved(agent))) { flag = true; break; } } if (flag) { continue; } } if (!isRain || actionPoint1.AreaType == MapArea.AreaType.Indoor) { MapArea ownerArea = actionPoint1.OwnerArea; bool flag1; if (!toRelease.TryGetValue(ownerArea.AreaID, out flag1)) { toRelease[ownerArea.AreaID] = flag1 = Singleton <Manager.Map> .Instance.CheckAvailableMapArea(ownerArea.AreaID); } if (flag1 && (!isFollow ? actionPoint1.AgentEventType : actionPoint1.AgentDateEventType).Contains(eventType)) { switch (eventType) { case EventType.Eat: StuffItem carryingItem = agent.AgentData.CarryingItem; AgentProfile agentProfile = Singleton <Resources> .Instance.AgentProfile; ItemIDKeyPair[] canStandEatItems = Singleton <Resources> .Instance.AgentProfile.CanStandEatItems; bool flag2 = false; foreach (ItemIDKeyPair itemIdKeyPair in canStandEatItems) { if (carryingItem.CategoryID == itemIdKeyPair.categoryID && carryingItem.ID == itemIdKeyPair.itemID) { flag2 = true; break; } } ActionPointInfo outInfo; if (flag2) { PoseKeyPair eatDeskId1 = agentProfile.PoseIDTable.EatDeskID; PoseKeyPair eatDeskId2 = agentProfile.PoseIDTable.EatDeskID; if (actionPoint1.FindAgentActionPointInfo(EventType.Eat, eatDeskId1.poseID, out outInfo) || actionPoint1.FindAgentActionPointInfo(EventType.Eat, eatDeskId2.poseID, out outInfo)) { break; } continue; } PoseKeyPair eatDishId = agentProfile.PoseIDTable.EatDishID; if (actionPoint1.FindAgentActionPointInfo(EventType.Eat, eatDishId.poseID, out outInfo)) { break; } continue; case EventType.Search: SearchActionPoint searchActionPoint = actionPoint1 as SearchActionPoint; if (Object.op_Inequality((Object)searchActionPoint, (Object)null)) { int registerId = searchActionPoint.RegisterID; Dictionary <int, AIProject.SaveData.Environment.SearchActionInfo> searchActionLockTable = agent.AgentData.SearchActionLockTable; AIProject.SaveData.Environment.SearchActionInfo searchActionInfo1; if (!searchActionLockTable.TryGetValue(registerId, out searchActionInfo1)) { AIProject.SaveData.Environment.SearchActionInfo searchActionInfo2 = new AIProject.SaveData.Environment.SearchActionInfo(); searchActionLockTable[registerId] = searchActionInfo2; searchActionInfo1 = searchActionInfo2; } if (searchActionInfo1.Count < searchCount) { int tableId = searchActionPoint.TableID; StuffItem itemInfo = agent.AgentData.EquipedSearchItem(tableId); if (agent.SearchAreaID == 0) { if (tableId != 0 && tableId != 1 && tableId != 2 || !searchActionPoint.CanSearch(EventType.Search, itemInfo)) { continue; } break; } if (agent.SearchAreaID != searchActionPoint.TableID || !searchActionPoint.CanSearch(EventType.Search, itemInfo)) { continue; } break; } continue; } break; case EventType.Warp: WarpPoint warpPoint = actionPoint1 as WarpPoint; Dictionary <int, List <WarpPoint> > dictionary; List <WarpPoint> warpPointList; if (!Object.op_Inequality((Object)warpPoint, (Object)null) || !Singleton <Manager.Map> .Instance.WarpPointDic.TryGetValue(ownerArea.ChunkID, out dictionary) || (!dictionary.TryGetValue(warpPoint.TableID, out warpPointList) || warpPointList.Count < 2)) { continue; } break; } if (SetDesiredAction._navMeshPath == null) { SetDesiredAction._navMeshPath = new NavMeshPath(); } NavMeshHit navMeshHit; if (agent.NavMeshAgent.CalculatePath(actionPoint1.LocatedPosition, SetDesiredAction._navMeshPath) && SetDesiredAction._navMeshPath.get_status() == null && NavMesh.SamplePosition(actionPoint1.LocatedPosition, ref navMeshHit, meshSampleDistance, agent.NavMeshAgent.get_areaMask())) { destination.Add(actionPoint1); } } } } } DictionaryPool <int, bool> .Release(toRelease); }
private static bool CheckNeutral( AgentActor agent, ActionPoint pt, Dictionary <int, bool> availableArea, int searchCount, int chunkID, EventType eventType, bool isFollow, bool isRain, float sampleDistance) { if (Object.op_Equality((Object)pt, (Object)null) || Object.op_Equality((Object)pt.OwnerArea, (Object)null) || (!pt.IsNeutralCommand || pt.IsReserved(agent))) { return(false); } List <ActionPoint> connectedActionPoints = pt.ConnectedActionPoints; if (!connectedActionPoints.IsNullOrEmpty <ActionPoint>()) { foreach (ActionPoint actionPoint in connectedActionPoints) { if (!Object.op_Equality((Object)actionPoint, (Object)null) && (!actionPoint.IsNeutralCommand || actionPoint.IsReserved(agent))) { return(false); } } } if (isRain && pt.AreaType != MapArea.AreaType.Indoor) { return(false); } MapArea ownerArea = pt.OwnerArea; if (ownerArea.ChunkID == chunkID) { return(false); } bool flag1; if (!availableArea.TryGetValue(ownerArea.AreaID, out flag1)) { availableArea[ownerArea.AreaID] = flag1 = Singleton <Manager.Map> .Instance.CheckAvailableMapArea(ownerArea.AreaID); } if (!flag1 || !(!isFollow ? pt.AgentEventType : pt.AgentDateEventType).Contains(eventType)) { return(false); } switch (eventType) { case EventType.Eat: StuffItem carryingItem = agent.AgentData.CarryingItem; AgentProfile agentProfile = Singleton <Resources> .Instance.AgentProfile; ItemIDKeyPair[] canStandEatItems = Singleton <Resources> .Instance.AgentProfile.CanStandEatItems; bool flag2 = false; foreach (ItemIDKeyPair itemIdKeyPair in canStandEatItems) { if (carryingItem.CategoryID == itemIdKeyPair.categoryID && carryingItem.ID == itemIdKeyPair.itemID) { flag2 = true; break; } } if (flag2) { PoseKeyPair eatDeskId1 = agentProfile.PoseIDTable.EatDeskID; PoseKeyPair eatDeskId2 = agentProfile.PoseIDTable.EatDeskID; ActionPointInfo outInfo; if (!pt.FindAgentActionPointInfo(EventType.Eat, eatDeskId1.poseID, out outInfo) && !pt.FindAgentActionPointInfo(EventType.Eat, eatDeskId2.poseID, out outInfo)) { return(false); } break; } PoseKeyPair eatDishId = agentProfile.PoseIDTable.EatDishID; if (!pt.FindAgentActionPointInfo(EventType.Eat, eatDishId.poseID, out ActionPointInfo _)) { return(false); } break; case EventType.Search: SearchActionPoint searchActionPoint = pt as SearchActionPoint; if (Object.op_Inequality((Object)searchActionPoint, (Object)null)) { int registerId = searchActionPoint.RegisterID; Dictionary <int, AIProject.SaveData.Environment.SearchActionInfo> searchActionLockTable = agent.AgentData.SearchActionLockTable; AIProject.SaveData.Environment.SearchActionInfo searchActionInfo1; if (!searchActionLockTable.TryGetValue(registerId, out searchActionInfo1)) { AIProject.SaveData.Environment.SearchActionInfo searchActionInfo2 = new AIProject.SaveData.Environment.SearchActionInfo(); searchActionLockTable[registerId] = searchActionInfo2; searchActionInfo1 = searchActionInfo2; } if (searchActionInfo1.Count >= searchCount) { return(false); } int tableId = searchActionPoint.TableID; StuffItem itemInfo = agent.AgentData.EquipedSearchItem(tableId); if (agent.SearchAreaID == 0) { if (tableId != 0 && tableId != 1 && tableId != 2 || !searchActionPoint.CanSearch(EventType.Search, itemInfo)) { return(false); } break; } if (agent.SearchAreaID != searchActionPoint.TableID || !searchActionPoint.CanSearch(EventType.Search, itemInfo)) { return(false); } break; } break; case EventType.Warp: WarpPoint warpPoint = pt as WarpPoint; Dictionary <int, List <WarpPoint> > dictionary; List <WarpPoint> warpPointList; if (!Object.op_Inequality((Object)warpPoint, (Object)null) || !Singleton <Manager.Map> .Instance.WarpPointDic.TryGetValue(ownerArea.ChunkID, out dictionary) || (!dictionary.TryGetValue(warpPoint.TableID, out warpPointList) || warpPointList.Count < 2)) { return(false); } break; } if (SetDesiredActionOtherChunk._navMeshPath == null) { SetDesiredActionOtherChunk._navMeshPath = new NavMeshPath(); } NavMeshHit navMeshHit; return(agent.NavMeshAgent.CalculatePath(pt.LocatedPosition, SetDesiredActionOtherChunk._navMeshPath) && SetDesiredActionOtherChunk._navMeshPath.get_status() == null && NavMesh.SamplePosition(pt.LocatedPosition, ref navMeshHit, sampleDistance, agent.NavMeshAgent.get_areaMask())); }
void Start() { virtualPath = new NavMeshPath(); isAlive = true; }
void Start() { m_Agent = GetComponent <NavMeshAgent>(); m_Agent.isStopped = true; m_Path = new NavMeshPath(); }
void MoveCharacter(NavMeshPath virtualPath, float distance) { controlledAgent.SetPath(virtualPath); movementPoints -= distance; }
private void Start() { _myNavMeshAgent = GetComponent <NavMeshAgent>(); _navMeshPath = new NavMeshPath(); }
public bool IsPointOnNavMesh(Vector3 virtualDestination, NavMeshPath outPath) { return(controlledAgent.CalculatePath(virtualDestination, outPath)); }
private IEnumerator ClimbLadder(NavMeshAgent agent) { //Saving the path so after the climbing is finished it can continue its path NavMeshPath path = agent.path; agent.enabled = false; // Determining if the agent wants to climb up or down bool toTop = Vector3.Distance(agent.transform.position, ofl.startTransform.position) < Vector3.Distance(agent.transform.position, ofl.endTransform.position); #region Look at ladder float t = 0.0f; float timeToLookAtLadder = 0.3f; Vector3 agentForwardAtStart = agent.transform.forward; while (t <= 1.0f) { t += Time.deltaTime / timeToLookAtLadder; Vector3 lerped = Vector3.Lerp(agentForwardAtStart, -transform.forward, t); agent.transform.forward = lerped; yield return(null); } agent.transform.forward = -transform.forward; #endregion #region Movement on ladder if (toTop) { for (int i = 0; i < ladderPoints.Length; i++) { while (agent.transform.position != ladderPoints[i].position) { //urPos = agent.transform.position; Vector3 newPosition = Vector3.MoveTowards(agent.transform.position, ladderPoints[i].position, agent.speed * Time.deltaTime); agent.transform.position = newPosition; yield return(null); } } } else { for (int i = ladderPoints.Length - 1; i > -1; i--) { while (agent.transform.position != ladderPoints[i].position) { //urPos = agent.transform.position; Vector3 newPosition = Vector3.MoveTowards(agent.transform.position, ladderPoints[i].position, agent.speed * Time.deltaTime); agent.transform.position = newPosition; yield return(null); } } } #endregion agentsOnLadder.RemoveAt(agentsOnLadder.IndexOf(agent)); agent.enabled = true; agent.CompleteOffMeshLink(); agent.path = path; if (lastAgent == agent) { lastAgent = null; } yield return(null); }
public bool IsPointOnNavMesh() { NavMeshPath path = new NavMeshPath(); return(controlledAgent.CalculatePath(hitInfo.point, path)); }
//------------------------------------------------- #if (UNITY_5_4) public static float PathLength(NavMeshPath path)
// Update is called once per frame void Update() { if (BlueList != null) { object[] obj = GameObject.FindSceneObjectsOfType(typeof(GameObject)); foreach (object o in obj) { GameObject g = (GameObject)o; if (g.tag == "blue") { if (BlueList.Contains(g) == false) { BlueList.Add(g); } } float randPay = Random.Range(0, 1); if (randPay == 0) { if (g.tag == "Pay") { pay = g; } } else { if (g.tag == "Pay2") { pay = g; } } } } if (BlueList != null) { goingPay = true; if (bought == false) { bought = true; randNumb = Random.Range(0, BlueList.Count - 1); distance = (BlueList[randNumb].transform.position - transform.position).magnitude; NavMeshPath nerdPath = new NavMeshPath(); m_agent.CalculatePath(BlueList[randNumb].transform.position, nerdPath); Vector3[] pathCorners = new Vector3[nerdPath.corners.Length]; nerdPath.corners.CopyTo(pathCorners, 0); seek.SetPathCorners(pathCorners); } else { float distance2 = (BlueList[randNumb].transform.position - transform.position).magnitude; if (distance2 <= 2.0f) { animator.SetBool("Buy", true); animatorGame.SetTrigger("Create"); animatorGame.SetBool("HasGame", true); BuyTimer -= Time.deltaTime; if (BuyTimer <= 0.1f) { BlueList.Clear(); BlueList = null; BuyTimer = 5.0f; } } } } else { if (goingPay == true) { goingPay = false; distance = (pay.transform.position - transform.position).magnitude; NavMeshPath goHome = new NavMeshPath(); m_agent.CalculatePath(pay.transform.position, goHome); Vector3[] goHomePath = new Vector3[goHome.corners.Length]; goHome.corners.CopyTo(goHomePath, 0); seek.SetPathCorners(goHomePath); } else { float distance3 = (pay.transform.position - transform.position).magnitude; if (distance3 > 1.5f) { animator.SetBool("Buy", false); animatorGame.SetTrigger("Destroy"); animatorGame.SetBool("HasGame", false); } else { animator.SetBool("Buy", true); BuyTimer -= Time.deltaTime; if (BuyTimer <= 0.1f) { Destroy(this.gameObject); BuyTimer = 5.0f; } } } } }
internal void CopyPathTo(NavMeshPath path){}
void Start() { animator = GetComponent <Animator>(); nav = GetComponent <NavMeshAgent>(); navMeshPath = new NavMeshPath(); }
private bool CalculatePathInternal(Vector3 targetPosition, NavMeshPath path){}
void FindTarget() { NavMeshPath pathToPlayer = new NavMeshPath(); agent.CalculatePath(playerObj.transform.position, pathToPlayer); float lengthToPlayer = 0.0F; if (pathToPlayer.corners.Length > 0) { Vector3 previousCorner = pathToPlayer.corners[0]; int i = 1; while (i < pathToPlayer.corners.Length) { Vector3 currentCorner = pathToPlayer.corners[i]; lengthToPlayer += Vector3.Distance(previousCorner, currentCorner); previousCorner = currentCorner; i++; } } NavMeshPath pathToBox = new NavMeshPath(); agent.CalculatePath(boxObj.transform.position, pathToBox); float lengthToBox = 0.0F; if (pathToBox.corners.Length > 0) { Vector3 previousCorner2 = pathToBox.corners[0]; int j = 1; while (j < pathToBox.corners.Length) { Vector3 currentCorner = pathToBox.corners[j]; lengthToBox += Vector3.Distance(previousCorner2, currentCorner); previousCorner2 = currentCorner; j++; } } if (lengthToBox == 0 && lengthToPlayer == 0) { state = EnemyState.Idle; anim.SetTrigger("Idle"); } else if (lengthToBox == 0) { state = EnemyState.MovingToPlayer; } else if (lengthToPlayer == 0) { state = EnemyState.MovingToBox; } else if (lengthToBox > lengthToPlayer) { state = EnemyState.MovingToPlayer; } else { state = EnemyState.MovingToBox; } }
public static bool CalculatePath(Vector3 sourcePosition, Vector3 targetPosition, int passableMask, NavMeshPath path){}
private void MoveToTarget() { target = new Vector3(0, 0, 0); NavMeshPath path = new NavMeshPath(); for (int k = 0; k < 50 && !agent.CalculatePath(target, path); k++) { target = new Vector3(transform.position.x - 5.01f, transform.position.y + Random.Range(-5, 5), transform.position.z); } if (!agent.CalculatePath(target, path)) { for (int k = 0; k < 50 && !agent.CalculatePath(target, path); k++) { target = new Vector3(transform.position.x - 4.01f, transform.position.y + Random.Range(-5, 5), transform.position.z); } } if (!agent.CalculatePath(target, path)) { for (int k = 0; k < 50 && !agent.CalculatePath(target, path); k++) { target = new Vector3(transform.position.x - 3.01f, transform.position.y + Random.Range(-5, 5), transform.position.z); } } if (!agent.CalculatePath(target, path)) { for (int k = 0; k < 50 && !agent.CalculatePath(target, path); k++) { target = new Vector3(transform.position.x - 2.01f, transform.position.y + Random.Range(-5, 5), transform.position.z); } } if (!agent.CalculatePath(target, path)) { for (int k = 0; k < 50 && !agent.CalculatePath(target, path); k++) { target = new Vector3(transform.position.x - 1.01f, transform.position.y + Random.Range(-5, 5), transform.position.z); } } if (!agent.CalculatePath(target, path)) { for (int k = 0; k < 50 && !agent.CalculatePath(target, path); k++) { target = new Vector3(transform.position.x - 0.01f, transform.position.y + Random.Range(-5, 5), transform.position.z); } } if (Input.GetKey(KeyCode.A)) { target.z -= 16; } if (Input.GetKey(KeyCode.D)) { target.z += 16; } Debug.Log(agent.CalculatePath(target, path)); agent.SetDestination(target); //Move towards point }
private static bool INTERNAL_CALL_CalculatePathInternal(ref Vector3 sourcePosition, ref Vector3 targetPosition, int passableMask, NavMeshPath path){}
public void RecordAgentState(ref NavMeshAgent agent) { lastAgentVelocity = agent.velocity; lastAgentPath = agent.path; lastAgentDestination = agent.destination; }