NavmestAgent SetDestination Doest work

hi guys,
i create navmeshagent and use setdestination but my character doesn’t move

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

public class UnitManager : MonoBehaviour
{
    private Ray Ray;
    private RaycastHit Hit;
    private float moveSpeed = 10.0f;
    private List<GameObject> selectedUnits = new List<GameObject>();
    public NavMeshAgent unitAgent;
    private Animator unitAnimation;

    // Start is called before the first frame update
    void Start()
    {
    }

    // Update is called once per frame
    void Update()
    {
       
    }

    public void SelectUnit(Transform Unit)
    {
        DeselectUnit();
        selectedUnits.Add(Unit.gameObject);
        Unit.Find("SelectionIndicator").gameObject.SetActive(true);
    }

    public void MultipleSelectUnit()
    {

    }

    public void DeselectUnit()
    {
        foreach (GameObject unit in selectedUnits)
        {
            unit.transform.Find("SelectionIndicator").gameObject.SetActive(false);
        }
        selectedUnits.Clear();
    }

    public void MoveUnit(Touch touch)
    {
        foreach (GameObject unit in selectedUnits)
        {
            unit.GetComponent<Animator>().SetInteger("toDo",6);
            unitAgent.SetDestination(touch.position);
        }
    }
   
}

Well, how do you call this MoveUnit method?
Also, does it work if you comment out the Animator set before the SetDestination? It’s very possible the GetComponent call is throwing a NullReferenceException causing the entire method to simply stop there.

For future reference, please only post the relevant code and include any error messages you might be getting.

Have you tried to debug your MoveUnit, like printing out the touch position? First verify that it is valid position in the world and not some wrong coordinate (might be million reasons for that kind of mistake/error) and then check if the path exists and if the path is valid. If I remember correctly, NavMeshAgent.pathStatus gives the current status of the path (valid/invalid). If the path exists and is valid, then continue searching for the cause elsewhere.

thanks guys, i already solve it, the problem is with my vector, i should not use touch,position, instead i should use hit.point