当前位置:网站首页>【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);
}
}
}
边栏推荐
- ESP8266-Arduino programming example-GA1A12S202 logarithmic scale analog light sensor
- 8年软件测试工程师感悟 —— 写给还在迷茫中的朋友
- 信息录入率百分百上海强化施工现场建筑工人实名制管理
- 链滴的几个 Markdown 语法没有渲染
- 如何防止重复下单?
- ODrive开发 #1 ODrive固件开发指南[通俗易懂]
- 测试工程师进阶必读书目
- LeetCode50天刷题计划(Day 9—— 整数转罗马数字(20.40-22.10)
- bug- 切换代理服务器与同步 bug
- 美国弗吉尼亚大学、微软 | Active Data Pattern Extraction Attacks on Generative Language Models(对生成语言模型的主动数据模式提取攻击)
猜你喜欢
ESP8266-Arduino programming example-GA1A12S202 logarithmic scale analog light sensor
May 20, 2022 The most complete fish game navigation
清华教授发文劝退读博:我见过太多博士生精神崩溃、心态失衡、身体垮掉、一事无成!...
Ant discloses the open source layout of core basic software technology for the first time
七夕专属博文-使用QGraphics画“红心“或“黑心“(含数学模型讲解)
便携烙铁开源系统IronOS,支持多款便携DC, QC, PD供电烙铁,支持所有智能烙铁标准功能
uniapp 获取cookie与携带cookie请求数据
会议OA项目(六)--- (待开会议、历史会议、所有会议)
MySQL [create and manage tables]
DOM树jsjs特效代码
随机推荐
pytorch测试的时候为何要加上model.eval()?
面试必问的HashCode技术内幕
中国驻西班牙使馆再次提醒留学人员注意暑期安全
Row locks in MySQL
Break the limit of file locks and use storage power to help enterprises grow new momentum
Eslint syntax error is solved
链滴的几个 Markdown 语法没有渲染
2022-08-01 Daily: 18 graphs to intuitively understand neural networks, manifolds and topology
A full review of mainstream timed task solutions
Grid布局 容器属性(一) `grid-template`系列属性
华盛顿大学、Allen AI 等联合 | RealTime QA: What's the Answer Right Now?(实时 QA:现在的答案是什么?)
ESP8266-Arduino编程实例-74HC595位移寄存驱动
ESP8266-Arduino programming example-GA1A12S202 logarithmic scale analog light sensor
Why should model.eval() be added to the pytorch test?
全新升级!《云原生架构白皮书 2022 版》重磅发布
Spark: Cluster Computing with Working Sets
Grafana9.0发布,Prometheus和Loki查询生成器、全新导航、热图面板等新功能!
BPM是什么意思?BPM的优势及好处有哪些?
VIM实用指南(-1)VIM的前世今生
预定义和自定义