Now About Social Code
summaryrefslogtreecommitdiff
path: root/scripts/bsp_level_generator.gd
diff options
context:
space:
mode:
authorLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2024-09-22 15:33:22 +0100
committerLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2024-09-22 15:33:22 +0100
commite9b2e264f767da4e630a515ae3217f3966be9ce6 (patch)
tree3f7517104ed7061eb9be9e9d70b9abefa10cac80 /scripts/bsp_level_generator.gd
parent5f6ba92130f55ec81f2336d488743c6ff2aeaf74 (diff)
bsp_level_generator: Create navigation mesh
Also make enemy AI use nav mesh for finding player
Diffstat (limited to 'scripts/bsp_level_generator.gd')
-rw-r--r--scripts/bsp_level_generator.gd11
1 files changed, 10 insertions, 1 deletions
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)