From e9b2e264f767da4e630a515ae3217f3966be9ce6 Mon Sep 17 00:00:00 2001 From: Lucas Fryzek Date: Sun, 22 Sep 2024 15:33:22 +0100 Subject: bsp_level_generator: Create navigation mesh Also make enemy AI use nav mesh for finding player --- scripts/bsp_level_generator.gd | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'scripts/bsp_level_generator.gd') diff --git a/scripts/bsp_level_generator.gd b/scripts/bsp_level_generator.gd index 5d70569..87806e2 100644 --- a/scripts/bsp_level_generator.gd +++ b/scripts/bsp_level_generator.gd @@ -123,7 +123,16 @@ func generate_geo(grid: Array[Tile]): csg_root.add_child(box) csg_root.use_collision = true - add_child(csg_root) + $NavigationRegion3D.add_child(csg_root) + + # We need to delay baking the nav mesh as + # the CSG won't be generated immediately + call_deferred("bake_nav") + +func bake_nav(): + print("Baking mesh") + $NavigationRegion3D.bake_navigation_mesh(false) + print("done baking") func _ready() -> void: var starting_axis = randi_range(0, 1) -- cgit