Now About Social Code
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2024-09-22 19:57:04 +0100
committerLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2024-09-22 19:57:04 +0100
commit84bb8cbec9dd17fd86885f378208ebfec96a3f77 (patch)
treef9a1660ad23d4f674e271e5f825af3dbf8168151
parent599c8dd969ca3eec1767eaf3585ae9a32d23fa57 (diff)
bsp_level_generator: Fix navmesh generation
Make it so doors generate properly in the navigation mesh
-rw-r--r--prefabs/bsp_level_generator.tscn2
-rw-r--r--scripts/bsp_level_generator.gd5
-rw-r--r--scripts/enemy.gd5
3 files changed, 10 insertions, 2 deletions
diff --git a/prefabs/bsp_level_generator.tscn b/prefabs/bsp_level_generator.tscn
index f9e05db..6d8fa48 100644
--- a/prefabs/bsp_level_generator.tscn
+++ b/prefabs/bsp_level_generator.tscn
@@ -7,6 +7,8 @@
[sub_resource type="NavigationMesh" id="NavigationMesh_q1fo6"]
geometry_parsed_geometry_type = 1
geometry_collision_mask = 4294967041
+agent_radius = 0.25
+region_min_size = 1.0
[node name="BspLevelGenerator" type="Node3D"]
script = ExtResource("1_6jn1x")
diff --git a/scripts/bsp_level_generator.gd b/scripts/bsp_level_generator.gd
index 2243481..ac095ef 100644
--- a/scripts/bsp_level_generator.gd
+++ b/scripts/bsp_level_generator.gd
@@ -7,7 +7,7 @@ extends Node3D
@export_category("Geometry Generator")
## Geometry generation config
-@export var wall_thickness: float = 1.25
+@export var wall_thickness: float = 1.3
@onready var mesh: MeshInstance3D = $MeshInstance3D
@@ -140,6 +140,7 @@ func generate_geo(grid: Array[Tile], array: Array):
generate_plane(array, Vector3(x, 2, y+1), [Vector3(1, 0, 0), Vector3(0, -2, 0)], Vector3.BACK)
generate_plane(array, Vector3(x+1, 2, y+1), [Vector3(0, 0, -1), Vector3(0, -2, 0)], Vector3.LEFT)
generate_plane(array, Vector3(x+1, 2, y), [Vector3(-1, 0, 0), Vector3(0, -2, 0)], Vector3.FORWARD)
+ pass
func _ready() -> void:
var starting_axis = randi_range(0, 1)
@@ -164,3 +165,5 @@ func _ready() -> void:
var tri_mesh = mesh.mesh.create_trimesh_shape()
$NavigationRegion3D/StaticBody3D/CollisionShape3D.shape = tri_mesh
$NavigationRegion3D.bake_navigation_mesh()
+
+ #ResourceSaver.save(mesh.mesh, "res://map.tres", ResourceSaver.FLAG_COMPRESS)
diff --git a/scripts/enemy.gd b/scripts/enemy.gd
index 1c4c063..716493c 100644
--- a/scripts/enemy.gd
+++ b/scripts/enemy.gd
@@ -67,10 +67,13 @@ func chase_nav_mesh(delta: float):
# We only want to navigate on XZ plane
new_velocity.y = 0
- velocity = new_velocity
+ velocity = velocity.move_toward(new_velocity, .25)
if not is_on_floor() and gravity_enabled:
velocity.y -= gravity * delta
+ else:
+ velocity.y = 0
+
move_and_slide()
func _physics_process(delta: float) -> void: