summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordusoleil <howcansocksbereal@gmail.com>2022-09-16 08:45:53 -0400
committerdusoleil <howcansocksbereal@gmail.com>2022-09-16 08:45:53 -0400
commit0b7daa101c282fe83b6d75b080e25d0e2147253f (patch)
tree04b5af2ed9dddbcb2dc765c28b1af22de74d40f5
parentf8d1f2dc1bd6356c33d023629fbef27f362c7aa2 (diff)
downloadgodot_wildjam_49-0b7daa101c282fe83b6d75b080e25d0e2147253f.tar.gz
godot_wildjam_49-0b7daa101c282fe83b6d75b080e25d0e2147253f.zip
Add Trigger in lower hallway to hide water below deck
-rw-r--r--Main.gd7
-rw-r--r--Main.tscn10
-rw-r--r--Trigger.gd12
-rw-r--r--Trigger.tscn28
-rw-r--r--character/fps_controller/fps_controller.tscn2
-rw-r--r--project.godot3
6 files changed, 60 insertions, 2 deletions
diff --git a/Main.gd b/Main.gd
new file mode 100644
index 0000000..15acb18
--- /dev/null
+++ b/Main.gd
@@ -0,0 +1,7 @@
+extends Spatial
+
+func _on_lower_deck_trigger_exited():
+ $"Water".visible = true
+
+func _on_lower_deck_trigger_entered():
+ $"Water".visible = false
diff --git a/Main.tscn b/Main.tscn
index b377c9a..9d305e6 100644
--- a/Main.tscn
+++ b/Main.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=18 format=2]
+[gd_scene load_steps=20 format=2]
[ext_resource path="res://character/fps_controller/fps_controller.tscn" type="PackedScene" id=1]
[ext_resource path="res://ship/ship/ship.tscn" type="PackedScene" id=2]
@@ -8,6 +8,8 @@
[ext_resource path="res://World.gd" type="Script" id=6]
[ext_resource path="res://Ship.gd" type="Script" id=7]
[ext_resource path="res://FPS.gd" type="Script" id=8]
+[ext_resource path="res://Main.gd" type="Script" id=9]
+[ext_resource path="res://Trigger.tscn" type="PackedScene" id=10]
[sub_resource type="BoxShape" id=19]
extents = Vector3( 1000, 0.1, 1000 )
@@ -41,6 +43,7 @@ radius = 11.4853
height = 97.7559
[node name="Main" type="Spatial"]
+script = ExtResource( 9 )
[node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( -0.560061, -0.107905, 0.821394, 0, 0.991481, 0.130249, -0.828452, 0.0729474, -0.55529, 0, 10, 0 )
@@ -156,6 +159,9 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 17, 44 )
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 70 )
far = 5000.0
+[node name="lower_deck_trigger" parent="ShipRigidBody" instance=ExtResource( 10 )]
+transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 3.43947, 1.05268, 34.1792 )
+
[node name="crates" type="Spatial" parent="."]
[node name="crate" parent="crates" instance=ExtResource( 5 )]
@@ -1904,3 +1910,5 @@ margin_bottom = 68.0
script = ExtResource( 8 )
[connection signal="body_exited" from="WorldGenCull" to="World" method="_on_WorldGenCull_body_exited"]
+[connection signal="entered" from="ShipRigidBody/lower_deck_trigger" to="." method="_on_lower_deck_trigger_entered"]
+[connection signal="exited" from="ShipRigidBody/lower_deck_trigger" to="." method="_on_lower_deck_trigger_exited"]
diff --git a/Trigger.gd b/Trigger.gd
new file mode 100644
index 0000000..b8bc471
--- /dev/null
+++ b/Trigger.gd
@@ -0,0 +1,12 @@
+extends Spatial
+
+signal entered
+signal exited
+
+func _on_Inside_body_exited(body:Node):
+ if $Outside.overlaps_body(body):
+ emit_signal("exited")
+
+func _on_Outside_body_exited(body:Node):
+ if $Inside.overlaps_body(body):
+ emit_signal("entered")
diff --git a/Trigger.tscn b/Trigger.tscn
new file mode 100644
index 0000000..0f5b6b9
--- /dev/null
+++ b/Trigger.tscn
@@ -0,0 +1,28 @@
+[gd_scene load_steps=3 format=2]
+
+[ext_resource path="res://Trigger.gd" type="Script" id=1]
+
+[sub_resource type="BoxShape" id=1]
+extents = Vector3( 1, 1, 0.3 )
+
+[node name="Trigger" type="Spatial"]
+script = ExtResource( 1 )
+
+[node name="Outside" type="Area" parent="."]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.2 )
+collision_layer = 128
+collision_mask = 0
+
+[node name="CollisionShape" type="CollisionShape" parent="Outside"]
+shape = SubResource( 1 )
+
+[node name="Inside" type="Area" parent="."]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.2 )
+collision_layer = 128
+collision_mask = 0
+
+[node name="CollisionShape" type="CollisionShape" parent="Inside"]
+shape = SubResource( 1 )
+
+[connection signal="body_exited" from="Outside" to="." method="_on_Outside_body_exited"]
+[connection signal="body_exited" from="Inside" to="." method="_on_Inside_body_exited"]
diff --git a/character/fps_controller/fps_controller.tscn b/character/fps_controller/fps_controller.tscn
index 4bea03f..e803e5b 100644
--- a/character/fps_controller/fps_controller.tscn
+++ b/character/fps_controller/fps_controller.tscn
@@ -11,7 +11,7 @@ radius = 0.374691
height = 0.0688557
[node name="fps_controller" type="KinematicBody"]
-collision_mask = 20
+collision_mask = 148
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="."]
diff --git a/project.godot b/project.godot
index 0b05f85..2728622 100644
--- a/project.godot
+++ b/project.godot
@@ -110,6 +110,9 @@ camera_swap={
3d_physics/layer_4="Obstacles"
3d_physics/layer_5="Items"
3d_physics/layer_6="World Gen"
+3d_physics/layer_7="Death Plane"
+3d_physics/layer_8="Triggers"
+3d_physics/layer_9="Interactables"
[physics]