unity 自动寻路开始,人物播放行走动画,到达目的地播放站立动画。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class RobotManager : MonoBehaviour
{
public NavMeshAgent robotNav;
public Transform target;
void Start()
{
}
// Update is called once per frame
void Update()
{
robotNav.SetDestination(target.position);
if (robotNav.velocity.sqrMagnitude == 0)
transform.GetComponent<Animator>().SetBool("isWalk", false);
else
transform.GetComponent<Animator>().SetBool("isWalk", true);
}
}