使用 NavigationMap
NavigationMap 即导航地图,是抽象的导航世界,位于 NavigationServer 中,使用 NavigationServer 的 RID 标识。
A map can hold and connect a near infinite number of navigation regions with navigation meshes to build the traversable areas of a game world for pathfinding.
A map can contain avoidance agents. Collision avoidance will be calculated based on the agents present in the map.
备注
Different NavigationMaps are completely isolated from each other but navigation regions and avoidance agents can switch between different maps. Switches will become effective on NavigationServer synchronization.
默认导航地图
Godot 默认会为根视口的每个 World2D 和 World3D 创建一个导航地图。
默认的 2D 导航地图 RID 可以从继承自 Node2D 的任何 Node 的 get_world_2d().get_navigation_map()
获取。
默认的 3D 导航地图 RID 可以从继承自 Node3D 的任何 Node 的 get_world_3d().get_navigation_map()
获取。
GDScript
extends Node2D
var default_2d_navigation_map_rid: RID = get_world_2d().get_navigation_map()
GDScript
extends Node3D
var default_3d_navigation_map_rid: RID = get_world_3d().get_navigation_map()
新建导航地图
The NavigationServer can create and support as many navigation maps as required for specific gameplay. Additional navigation maps are created and handled by using the NavigationServer API directly e.g. to support different avoidance agent or actor locomotion types.
For example uses of different navigation maps see 支持不同角色类型 and 支持不同角色运动.
Each navigation map individually synchronizes queued changes to its navigation regions and avoidance agents. A navigation map that has not received changes will consume little to no processing time. Navigation regions and avoidance agents can only be part of a single navigation map but they can switch map at any time.
备注
A navigation map switch will take effect only after the next NavigationServer synchronization.
GDScript
extends Node2D
var new_navigation_map: RID = NavigationServer2D.map_create()
NavigationServer2D.map_set_active(true)
GDScript
extends Node3D
var new_navigation_map: RID = NavigationServer3D.map_create()
NavigationServer3D.map_set_active(true)
备注
There is no difference between navigation maps created with the NavigationServer2D API or the NavigationServer3D API.
© 版权所有 2014-present Juan Linietsky, Ariel Manzur and the Godot community (CC BY 3.0). Revision b1c660f7
.
Built with Sphinx using a theme provided by Read the Docs.