Hello everyone!
I’m working on an AR-based indoor navigation app and using this script to display the path. Additionally, I’ve added this script to the indicator.
using UnityEngine;
using UnityEngine.AI;
public class SetNavigationTarget : MonoBehaviour
{
[SerializeField]
private Camera TopDownCamera;
[SerializeField]
private GameObject NavTargetObject;
private NavMeshPath path; // current calculated path
private LineRenderer Line; // LineRender to display path
private bool LineToggle = false;
private void Start()
{
path = new NavMeshPath();
Line = transform.GetComponent<LineRenderer>();
}
private void Update()
{
if ((Input.touchCount > 0)&&(Input.GetTouch(0).phase==TouchPhase.Began))
{
LineToggle = !LineToggle;
}
if (LineToggle)
{
NavMesh.CalculatePath(transform.position, NavTargetObject.transform.position, NavMesh.AllAreas, path);
Line.positionCount = path.corners.Length;
Line.SetPositions(path.corners);
Line.enabled = true;
}
}
}
However, after building and testing the app, the path doesn’t appear when I tap the screen. What could be causing this issue?