当前位置:网站首页>【Unity,C#】哨兵点位循迹模板代码
【Unity,C#】哨兵点位循迹模板代码
2022-08-01 16:02:00 【mozhimen】
哨兵点位循迹模板代码
效果
配置

代码
public class Sentry : MonoBehaviour
{
private NavMeshAgent _navMeshAgent;
private int _currentWaypointIndex = 0;
public Transform[] waypoints;
private void Start()
{
_navMeshAgent = GetComponent<NavMeshAgent>();
_navMeshAgent.SetDestination(waypoints[_currentWaypointIndex].position);
}
private void Update()
{
if (_navMeshAgent.remainingDistance <= _navMeshAgent.stoppingDistance)
{
_currentWaypointIndex = (_currentWaypointIndex + 1) % waypoints.Length;
_navMeshAgent.SetDestination(waypoints[_currentWaypointIndex].position);
}
}
}
边栏推荐
猜你喜欢

gconf/dconf实战编程(2)利用gconf库读写配置实战以及诸多配套工具演示

清华教授发文劝退读博:我见过太多博士生精神崩溃、心态失衡、身体垮掉、一事无成!...
![MySQL [create and manage tables]](/img/5f/fc5d278f32df859e2c454b6d8467ed.png)
MySQL [create and manage tables]

Spark: Cluster Computing with Working Sets

mysql 面试题

0-1背包问题的一维数组优化解析

Spark: Cluster Computing with Working Sets

HashCode technology insider interview must ask

gconf/dconf编程实战(1)gconf和dconf介绍

使用Canvas实现网页鼠标签名效果
随机推荐
MUI as a mobile phone to return to the action bar
js to determine whether it is a pc or a mobile terminal (including ipad)
五分钟带你上手ShardingJDBC实现MySQL分库分表
canvas粒子雨动画js特效
pytorch测试的时候为何要加上model.eval()?
LeetCode50天刷题计划(Day 9—— 整数转罗马数字(20.40-22.10)
Digicert EV证书签名后出现“证书对于请求用法无效”的解决方案
untiy Resorces目录动态加载资源
A full review of mainstream timed task solutions
DOM系列之触屏事件
Spark: Cluster Computing with Working Sets
DOM series of touch screen events
Zhaoqi Science and Technology Innovation Event Platform, Entrepreneurship Event Roadshow, Online Live Roadshow
信息录入率百分百上海强化施工现场建筑工人实名制管理
Stored procedures in MySQL (detailed)
LeetCode50天刷题计划(Day 10—— 三数之和(20.50-22.40)
会议OA项目(六)--- (待开会议、历史会议、所有会议)
gconf/dconf实战编程(2)利用gconf库读写配置实战以及诸多配套工具演示
HDU 2602: Bone Collector ← 0-1背包问题
uniapp 获取cookie与携带cookie请求数据