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);
}
}
}