To access navigation features, gw2cc offers a customized version of Godot’s NavigationServer.
Libcc provides an easy way to utilize it (libcc/navigation/NavigationMapInstance.gd)
. Assuming you created a new Bot using the Project->Tools->Create Mod
wizard, simply add a Node3D named NavigationMapInstance
to your bot scene and Drag & Drop NavigationMapInstance.gd
onto it. Right click the node, select "Access as unique node"
. Make sure this is not the first child of your BehaviorTree! In your BehaviorTree root node add this code snipped to the _on_controlled_character_spawned
function like so:
func _on_controlled_character_spawned(_cc: AgentChar) -> void:
var path = ContentService.get_asset_dir().path_join("map").path_join(str(Manager.mission.map_def.map_file) + ".res")
%NavigationMapInstance.map = load(path)
%NavigationMapInstance.mesh = await %NavigationMapInstance.load_nav_for_map(Manager.mission.get_map_id(),BOT_NAME)
_context["nav_map"] = %NavigationMapInstance.navigation_map
_start_b_tree()
unpause()
This would cause your bot to automagically load/create and save the generated NavigationMesh
for each map at \game_data\101\BOT_NAME
.
