当前位置:网站首页>【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);
}
}
}
边栏推荐
猜你喜欢
MUI as a mobile phone to return to the action bar
打破文件锁限制,以存储力量助力企业增长新动力
8年软件测试工程师感悟 —— 写给还在迷茫中的朋友
30分钟成为Contributor|如何多方位参与OpenHarmony开源贡献?
Timezone setting in MySQL
计算机系统与网络安全技术——第一章——信息安全概述——1.1-网络安全定义——什么是信息?
到底什么才是真正的商业智能(BI)
商业智能BI业务分析思维:供应链分析 - 什么是牛鞭效应(一)
华盛顿大学、Allen AI 等联合 | RealTime QA: What's the Answer Right Now?(实时 QA:现在的答案是什么?)
便携烙铁开源系统IronOS,支持多款便携DC, QC, PD供电烙铁,支持所有智能烙铁标准功能
随机推荐
月薪12K,蝶变向新勇往直前,我通过转行软件测试实现月薪翻倍...
数据抽取过滤的时候,数据库字段update_at类型是timestamp,抽取T-1日数据这个变量条
【repo】SyntaxError: invalid syntax
测试工程师进阶必读书目
Zhaoqi Science and Technology Innovation Event Platform, Entrepreneurship Event Roadshow, Online Live Roadshow
向mysql 传数据 这个字符串长度有限制么
"Find nearby shops" | Geohash+MySQL realizes geographic location filtering
DHCP配置命令(DHCP配置命令)
输出0-1背包问题的具体方案 ← 利用二维数组
美国弗吉尼亚大学、微软 | Active Data Pattern Extraction Attacks on Generative Language Models(对生成语言模型的主动数据模式提取攻击)
80篇国产数据库实操文档汇总(含TiDB、达梦、openGauss等)
VIM实用指南(-1)VIM的前世今生
urlopen error errno111(英雄联盟报错error)
mysql 面试题
选择合适的 DevOps 工具,从理解 DevOps 开始
CodeForces 570D Tree Requests
给网站增加离开页面改变网站标题效果
面试必问的HashCode技术内幕
untiy Resorces目录动态加载资源
接口测试框架开发实践5:配置文件读取