Now About Social Code
summaryrefslogtreecommitdiff
path: root/prefabs/bullet.tscn
AgeCommit message (Collapse)Author
2024-09-17Initial commitLucas Fryzek
) at 2024-11-15 01:35:04 +0000 >player: Add ammo and fire rateLucas Fryzek 2024-09-26dungeon_manager: Create 3D portal model with textureLucas Fryzek 2024-09-26bsp_level_generator: Add more models and texturesLucas Fryzek 2024-09-26enemy: Add alien model with basic animationsLucas Fryzek 2024-09-26bsp_level_generator: Add special door tileLucas Fryzek 2024-09-26dungeon_manager: Add level exit, and load new levelLucas Fryzek [...]  Clone https://git.fryzekconcepts.com/spacegame a>
@@ -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: