/// <summary> /// Calculate a path until reaching a destination /// </summary> /// <param name="_position">destination to reach</param> public void SetDestination(Vector2 _position) { if (NavMeshManager.Instance.Triangles == null || NavMeshManager.Instance.Triangles.Count == 0) { Debug.LogWarning("Triangles Not found. Must build the navmesh for the scene"); return; } if (PathCalculator.CalculatePath(transform.position, _position, out currentPath, NavMeshManager.Instance.Triangles)) { isMoving = true; currentIndex = 1; } }
/// <summary> /// Check if the destination can be reached /// </summary> /// <param name="_position">destination to reach</param> /// <returns>if the destination can be reached</returns> public bool CheckDestination(Vector2 _position) { if (NavMeshManager.Instance.Triangles == null || NavMeshManager.Instance.Triangles.Count == 0) { Debug.LogWarning("Triangles Not found. Must build the navmesh for the scene"); return(false); } bool _canBeReached = PathCalculator.CalculatePath(transform.position, _position, out currentPath, NavMeshManager.Instance.Triangles); if (_canBeReached) { isMoving = true; currentIndex = 1; } return(_canBeReached); }