[gd_scene load_steps=4 format=3 uid="uid://cmhycifu5uwoc"] [ext_resource type="Script" path="res://scripts/bullet.gd" id="1_3dasu"] [sub_resource type="BoxMesh" id="BoxMesh_bp3aw"] size = Vector3(0.05, 0.05, 1) [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_c2hx3"] shading_mode = 0 albedo_color = Color(0, 1, 0, 1) [node name="Bullet" type="Node3D"] script = ExtResource("1_3dasu") [node name="MeshInstance3D" type="MeshInstance3D" parent="."] mesh = SubResource("BoxMesh_bp3aw") surface_material_override/0 = SubResource("StandardMaterial3D_c2hx3") Lucas Fryzek's public projects
index
NameDescriptionOwnerIdle
sgx-reversingTools for reverse engineering the sgx540 GPU on a ci20 dev boardLucas Fryzek
spacegameUntitled space game made in Godot 4Lucas Fryzek
weegtkWeechat relay using Libadwaita and Gtk4Lucas Fryzek
enemy.tscn'>
path: root/prefabs/enemy.tscn
diff options
context:
space:
mode:
Diffstat (limited to 'prefabs/enemy.tscn')
-rw-r--r--prefabs/enemy.tscn16
1 files changed, 15 insertions, 1 deletions
diff --git a/prefabs/enemy.tscn b/prefabs/enemy.tscn
index 71e35f8..415b9b8 100644
--- a/prefabs/enemy.tscn
+++ b/prefabs/enemy.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=5 format=3 uid="uid://cuad3khwmhnsa"]
+[gd_scene load_steps=6 format=3 uid="uid://cuad3khwmhnsa"]
[ext_resource type="Script" path="res://scripts/enemy.gd" id="1_aut2k"]
@@ -8,6 +8,9 @@
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_s5qw4"]
+[sub_resource type="BoxShape3D" id="BoxShape3D_cyd43"]
+size = Vector3(20, 2, 20)
+
[node name="Enemy" type="CharacterBody3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.54414, -1.58742)
motion_mode = 1
@@ -28,4 +31,15 @@ wait_time = 0.2
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="."]
+[node name="VisionVolume" type="Area3D" parent="."]
+collision_layer = 4
+collision_mask = 4
+input_ray_pickable = false
+
+[node name="VisionVolumeShape" type="CollisionShape3D" parent="VisionVolume"]
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
+shape = SubResource("BoxShape3D_cyd43")
+
[connection signal="timeout" from="HitTimer" to="." method="_on_hit_timer_timeout"]
+[connection signal="body_entered" from="VisionVolume" to="." method="_on_body_entered"]
+[connection signal="body_exited" from="VisionVolume" to="." method="_on_body_exited"]
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: