Hi
Problem Statement : How do I trigger the stop animation command when my player has reached the destination.
private void Update()
{
if (Input.GetMouseButtonDown(0))
{
MoveToCursor();
}
}
private void MoveToCursor()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
bool hasHit = Physics.Raycast(ray, out hit);
var hitPoint = hit.point;
hitPoint.z = 0;
float x = 0.3f;
var playerPosition = transform.position;
playerPosition.z = 0;
var distance = Vector3.Distance(hitPoint,playerPosition);
Debug.Log($"Distance: {distance}", this);
if(hasHit)
{
GetComponent<NavMeshAgent>().destination = hit.point;
unitAnimator.SetBool("IsWalking", true);
}
}
So I need to creation a condition where I can check that the distance has been reached and run
unitAnimator.SetBool(“IsWalking”, false);
But my brain is not getting out of gear on this one