My unit does not understand that it cannot reach the destination.
See the gif below:
the unit becomes red if ai.reachedDestination = true and is cyan when ai.reachedDestination = false.
How can I know when the destination is reached? (meaning the unit can’t go any further on the path it is on)
The script I’m using:
public class Test : MonoBehaviour
{
public Transform Destination;
private AIPath Path;
private MeshRenderer Mr;
void Awake()
{
Path = GetComponent<AIPath>();
Mr= GetComponentInChildren<MeshRenderer>();
}
void Update()
{
if (Destination != null)
{
Path.destination = Destination.position;
if (Path.reachedDestination)
{
Mr.material.color = Color.red;
}
else
{
Mr.material.color = Color.cyan;
}
}
}
}