导航网络

需要作为地形的父节点 需要点击工具栏 -> 烘焙导航网络


参数Geometry/Parsed Geometry Type:使用哪个几何体来计算导航

选项 描述
Mesh Instances 使用静态模型,即MeshInstance3D节点
Static Colliders 使用静态碰撞,即StaticBody3D节点
Both 两者

导航器

需要作为需要导航的物体的子节点

设置目标

CS
public override void _Ready() {
	// 获取实例
	NavigationAgent3D agent = GetNode<NavigationAgent3D>("NavigationAgent3D");
	// 设置目标位置
	agent.TargetPosition = @Node.GlobalPosition;
}
点击展开查看更多

开始导航

CS
public override void _PhysicsProcess(double delta) {
	// 判断是否导航结束
	if (!agent.IsNavigationFinished()) {
		// 获取导航要去的位置
		Vector3 next = agent.GetNextPathPosition();
		// 处理
		// ...
	}
}
点击展开查看更多

路障

连接两个位于NavigationRegion3D上的位置的链接,导航时能够让代理走这个链接。

版权声明

作者: Chaim

链接: https://chaim.eu.org/posts/%E5%AF%BC%E8%88%AA/

许可证: CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the source, use non-commercially, and maintain the same license.

开始搜索

输入关键词搜索文章内容

↑↓
ESC
⌘K 快捷键