当前位置:网站首页>【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);
}
}
}
边栏推荐
猜你喜欢
Ant discloses the open source layout of core basic software technology for the first time
LeetCode50天刷题计划(Day 6—— 整数反转 14.20-15.20)
MUI 做手机返回操作栏
SQL query data and sorting
ECCV 2022 | Poseur:你以为我是姿态估计,其实是目标检测哒
Spark: Cluster Computing with Working Sets
主流定时任务解决方案全横评
MySQL:索引
2.8K 120Hz touch dual-screen blessing Lingyao X dual-screen Pro 2022 makes the office without fear of imagination
LeetCode50天刷题计划(Day 7—— 字符串转换整数 (atoi) 12.20-15.20)
随机推荐
信息录入率百分百上海强化施工现场建筑工人实名制管理
行程排序(暑假每日一题 12)
wordpress模板函数说明备注整理收藏
VIM使用指南(7)单词移动/删除技巧
DHCP配置命令(DHCP配置命令)
LeetCode50天刷题计划(Day 7—— 字符串转换整数 (atoi) 12.20-15.20)
May 20, 2022 The most complete fish game navigation
数据抽取过滤的时候,数据库字段update_at类型是timestamp,抽取T-1日数据这个变量条
全新升级!《云原生架构白皮书 2022 版》重磅发布
VIM实用指南(3)复制,粘贴 ,删除,撤销,重做指令速记
指针进阶(二)
leetcode:80. 删除有序数组中的重复项 II
SyntaxHighlighter带来的字符转义问题
指针进阶(三)之指针与数组笔试题
8年软件测试工程师感悟 —— 写给还在迷茫中的朋友
南京科技大学、中国电子科技第28研究所等联合|MLRIP: Pre-training a military language representation model with informative factual knowledge and professional knowledge base(预训练具有丰富事实知识和专业知识库的军事语言表示模型)
链滴的几个 Markdown 语法没有渲染
shell 基础之函数编写
【Untitled】
MySQL INTERVAL 关键字指南