public class RandomNav:MonoBehaviour
{
private NavMeshAgent agent;
public Transform point;
private float RandomTime;
void Start()
{
agent=GetComponent<NavMeshAgent>();
point.position=new Vector3(1,1,1);
agent.speed=0.3f;
}
void Update()
{
RandomTime+=Time.deltaTime;
}
//以状态来判断他的destination点
void Nav()
{
AnimatorStateInfo stateInfo = anim.GetCurrentAnimatorStateInfo(0);
if(stateInfo.IsName("Move"))
{
agent.speed=1;
agent.SetDestination(point.position);
}
else if(stateInfo.IsName("idle"))
{
float x=Random.Range(-52,10);
float x=Random.Range(13,62);
point.position=new Vector3(x,0,z);
}
}
}
随机寻路
最新推荐文章于 2024-08-05 22:30:40 发布