started adding completion system

This commit is contained in:
2024-01-19 12:53:24 +01:00
parent be95ec8202
commit 269729a1d9
13 changed files with 238 additions and 31 deletions

View File

@@ -0,0 +1,11 @@
[gd_scene load_steps=3 format=3 uid="uid://6njtmij7sikl"]
[ext_resource type="Script" path="res://scripts/completion_counter.gd" id="1_40xge"]
[sub_resource type="BoxMesh" id="BoxMesh_w280a"]
size = Vector3(1, 0.2, 0.1)
[node name="CompletionCounter" type="MeshInstance3D"]
editor_description = "The amount of signals it needs connected and fired to emit a signal"
mesh = SubResource("BoxMesh_w280a")
script = ExtResource("1_40xge")

63
scenes/door.tscn Normal file
View File

@@ -0,0 +1,63 @@
[gd_scene load_steps=7 format=3 uid="uid://cy0x2nliyw8gw"]
[ext_resource type="Script" path="res://scripts/door.gd" id="1_qix0h"]
[sub_resource type="BoxMesh" id="BoxMesh_8iti4"]
size = Vector3(1.5, 3, 0.2)
[sub_resource type="BoxShape3D" id="BoxShape3D_pejvk"]
size = Vector3(1.5, 3, 0.2)
[sub_resource type="Animation" id="Animation_53g2p"]
resource_name = "open"
length = 0.5
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.5),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector3(0, 0, 0), Vector3(1.4, 0, 0)]
}
[sub_resource type="Animation" id="Animation_hlq2m"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, 0, 0)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_r8evj"]
_data = {
"RESET": SubResource("Animation_hlq2m"),
"open": SubResource("Animation_53g2p")
}
[node name="Door" type="Node3D"]
script = ExtResource("1_qix0h")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = SubResource("BoxMesh_8iti4")
[node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D/StaticBody3D"]
shape = SubResource("BoxShape3D_pejvk")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
root_node = NodePath("../MeshInstance3D")
libraries = {
"": SubResource("AnimationLibrary_r8evj")
}

View File

@@ -67,14 +67,23 @@ transparent_bg = true
handle_input_locally = false handle_input_locally = false
gui_embed_subwindows = true gui_embed_subwindows = true
size = Vector2i(1152, 648) size = Vector2i(1152, 648)
size_2d_override_stretch = true
render_target_update_mode = 4 render_target_update_mode = 4
[node name="Node3D" type="Node3D" parent="SubViewportContainer/SubViewport"] [node name="Node3D" type="Node3D" parent="SubViewportContainer/SubViewport"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -8, 0)
[node name="MeshInstance3D" type="MeshInstance3D" parent="SubViewportContainer/SubViewport/Node3D"] [node name="DirectionalLight3D" type="DirectionalLight3D" parent="SubViewportContainer/SubViewport/Node3D"]
transform = Transform3D(0.707107, -0.5, 0.5, 0, 0.707107, 0.707107, -0.707107, -0.5, 0.5, 0, 0, 0)
directional_shadow_blend_splits = true
sky_mode = 1
metadata/_edit_lock_ = true
[node name="Camera3D" type="Camera3D" parent="SubViewportContainer/SubViewport/Node3D"]
[node name="MeshInstance3D" type="MeshInstance3D" parent="SubViewportContainer/SubViewport/Node3D/Camera3D"]
transform = Transform3D(0.00445237, 0.182181, 0.983255, 0.0240231, 0.982961, -0.182236, -0.999701, 0.0244322, -4.29794e-08, 0.895815, -0.569743, -1.63173) transform = Transform3D(0.00445237, 0.182181, 0.983255, 0.0240231, 0.982961, -0.182236, -0.999701, 0.0244322, -4.29794e-08, 0.895815, -0.569743, -1.63173)
mesh = ExtResource("1_803cf") mesh = ExtResource("1_803cf")
skeleton = NodePath("../..")
surface_material_override/0 = ExtResource("2_qrl87") surface_material_override/0 = ExtResource("2_qrl87")
surface_material_override/1 = SubResource("ShaderMaterial_twwch") surface_material_override/1 = SubResource("ShaderMaterial_twwch")
surface_material_override/2 = ExtResource("4_expk1") surface_material_override/2 = ExtResource("4_expk1")
@@ -82,7 +91,7 @@ surface_material_override/3 = ExtResource("5_algr0")
surface_material_override/4 = ExtResource("6_ocwsh") surface_material_override/4 = ExtResource("6_ocwsh")
surface_material_override/5 = ExtResource("7_c1s4a") surface_material_override/5 = ExtResource("7_c1s4a")
[node name="GPUParticles3D" type="GPUParticles3D" parent="SubViewportContainer/SubViewport/Node3D/MeshInstance3D"] [node name="GPUParticles3D" type="GPUParticles3D" parent="SubViewportContainer/SubViewport/Node3D/Camera3D/MeshInstance3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.20308, -0.000130415, 0.165362) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.20308, -0.000130415, 0.165362)
emitting = false emitting = false
lifetime = 5.0 lifetime = 5.0
@@ -91,7 +100,7 @@ visibility_aabb = AABB(-0.894568, -0.448322, -0.513538, 1.77742, 0.896643, 1.027
process_material = SubResource("ParticleProcessMaterial_yttr4") process_material = SubResource("ParticleProcessMaterial_yttr4")
draw_pass_1 = SubResource("QuadMesh_wtlns") draw_pass_1 = SubResource("QuadMesh_wtlns")
[node name="GPUParticles3D2" type="GPUParticles3D" parent="SubViewportContainer/SubViewport/Node3D/MeshInstance3D"] [node name="GPUParticles3D2" type="GPUParticles3D" parent="SubViewportContainer/SubViewport/Node3D/Camera3D/MeshInstance3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.173204, 0.0331628, -0.182098) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.173204, 0.0331628, -0.182098)
lifetime = 5.0 lifetime = 5.0
randomness = 0.5 randomness = 0.5
@@ -99,7 +108,7 @@ visibility_aabb = AABB(-0.894568, -0.448322, -0.513538, 1.77742, 0.896643, 1.027
process_material = SubResource("ParticleProcessMaterial_yttr4") process_material = SubResource("ParticleProcessMaterial_yttr4")
draw_pass_1 = SubResource("QuadMesh_wtlns") draw_pass_1 = SubResource("QuadMesh_wtlns")
[node name="GPUParticles3D3" type="GPUParticles3D" parent="SubViewportContainer/SubViewport/Node3D/MeshInstance3D"] [node name="GPUParticles3D3" type="GPUParticles3D" parent="SubViewportContainer/SubViewport/Node3D/Camera3D/MeshInstance3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.132698, 0.304665, 0.0594321) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.132698, 0.304665, 0.0594321)
lifetime = 5.0 lifetime = 5.0
randomness = 0.5 randomness = 0.5
@@ -107,11 +116,6 @@ visibility_aabb = AABB(-0.894568, -0.448322, -0.513538, 1.77742, 0.896643, 1.027
process_material = SubResource("ParticleProcessMaterial_yttr4") process_material = SubResource("ParticleProcessMaterial_yttr4")
draw_pass_1 = SubResource("QuadMesh_wtlns") draw_pass_1 = SubResource("QuadMesh_wtlns")
[node name="GPUParticlesCollisionBox3D" type="GPUParticlesCollisionBox3D" parent="SubViewportContainer/SubViewport/Node3D/MeshInstance3D"] [node name="GPUParticlesCollisionBox3D" type="GPUParticlesCollisionBox3D" parent="SubViewportContainer/SubViewport/Node3D/Camera3D/MeshInstance3D"]
transform = Transform3D(0.999923, -0.012392, 0.000616441, 0.0123854, 0.999875, 0.00980631, -0.000737865, -0.00979792, 0.999952, 0.358337, 0.108517, -0.0012207) transform = Transform3D(0.999923, -0.012392, 0.000616441, 0.0123854, 0.999875, 0.00980631, -0.000737865, -0.00979792, 0.999952, 0.358337, 0.108517, -0.0012207)
size = Vector3(1.17664, 0.301201, 0.299805) size = Vector3(1.17664, 0.301201, 0.299805)
[node name="Camera3D" type="Camera3D" parent="SubViewportContainer/SubViewport/Node3D"]
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="SubViewportContainer/SubViewport/Node3D"]
transform = Transform3D(0.991671, 0, -0.128796, 0, 1, 0, 0.128796, 0, 0.991671, 0, 0, 0)

View File

@@ -1,9 +1,11 @@
[gd_scene load_steps=7 format=3 uid="uid://ckad8stc13n83"] [gd_scene load_steps=9 format=3 uid="uid://ckad8stc13n83"]
[ext_resource type="PackedScene" uid="uid://gg5ph541e4p3" path="res://scenes/player.tscn" id="1_2585i"] [ext_resource type="PackedScene" uid="uid://gg5ph541e4p3" path="res://scenes/player.tscn" id="1_2585i"]
[ext_resource type="PackedScene" uid="uid://ddwkhfly2xyyt" path="res://models/interior.obj" id="1_lphcl"] [ext_resource type="PackedScene" uid="uid://ddwkhfly2xyyt" path="res://models/interior.obj" id="1_lphcl"]
[ext_resource type="PackedScene" uid="uid://b8bvidqu7tmfs" path="res://scenes/objects/interactables/task_terminal.tscn" id="3_30m3x"] [ext_resource type="PackedScene" uid="uid://b8bvidqu7tmfs" path="res://scenes/objects/interactables/task_terminal.tscn" id="3_30m3x"]
[ext_resource type="PackedScene" uid="uid://dqy8bqf1chm8c" path="res://scenes/objects/interactables/button_stand.tscn" id="4_cruoa"] [ext_resource type="PackedScene" uid="uid://dqy8bqf1chm8c" path="res://scenes/objects/interactables/button_stand.tscn" id="4_cruoa"]
[ext_resource type="PackedScene" uid="uid://6njtmij7sikl" path="res://scenes/completion_counter.tscn" id="5_lo1l3"]
[ext_resource type="PackedScene" uid="uid://cy0x2nliyw8gw" path="res://scenes/door.tscn" id="6_853p2"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_780x3"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_780x3"]
albedo_color = Color(0.133333, 0.133333, 0.133333, 1) albedo_color = Color(0.133333, 0.133333, 0.133333, 1)
@@ -38,4 +40,16 @@ transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0.5, 0
[node name="ButtonStand" parent="." instance=ExtResource("4_cruoa")] [node name="ButtonStand" parent="." instance=ExtResource("4_cruoa")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 0.7, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 0.7, 0)
[node name="CompletionCounter" parent="." node_paths=PackedStringArray("nodes_needed") instance=ExtResource("5_lo1l3")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0617981, 3.05379, 6.24098)
nodes_needed = [NodePath("../ButtonStand"), NodePath("../ButtonStand2")]
[node name="Door" parent="." instance=ExtResource("6_853p2")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.1, 1.425, 6.64)
[node name="ButtonStand2" parent="." instance=ExtResource("4_cruoa")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0.7, 4)
[connection signal="unlock" from="CompletionCounter" to="Door" method="open"]
[editable path="interior"] [editable path="interior"]

View File

@@ -1,7 +1,7 @@
[gd_scene load_steps=11 format=3 uid="uid://dqy8bqf1chm8c"] [gd_scene load_steps=11 format=3 uid="uid://dqy8bqf1chm8c"]
[ext_resource type="PackedScene" uid="uid://dm8l36ephydnl" path="res://scenes/interaction_area.tscn" id="1_0okd0"] [ext_resource type="PackedScene" uid="uid://dm8l36ephydnl" path="res://scenes/interaction_area.tscn" id="1_0okd0"]
[ext_resource type="Script" path="res://scripts/interactables/button_stand.gd" id="1_uieqm"] [ext_resource type="Script" path="res://scripts/interactables/completer/button_stand.gd" id="1_gkcm2"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_jpuiw"] [sub_resource type="CylinderShape3D" id="CylinderShape3D_jpuiw"]
height = 1.4 height = 1.4
@@ -25,6 +25,21 @@ top_radius = 0.2
bottom_radius = 0.2 bottom_radius = 0.2
height = 0.1 height = 0.1
[sub_resource type="Animation" id="Animation_y5bt0"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Button:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, 0.750413, 0)]
}
[sub_resource type="Animation" id="Animation_stg1c"] [sub_resource type="Animation" id="Animation_stg1c"]
resource_name = "press" resource_name = "press"
length = 0.2 length = 0.2
@@ -41,21 +56,6 @@ tracks/0/keys = {
"values": [Vector3(0, 0.750413, 0), Vector3(0, 0.67, 0), Vector3(0, 0.75, 0)] "values": [Vector3(0, 0.750413, 0), Vector3(0, 0.67, 0), Vector3(0, 0.75, 0)]
} }
[sub_resource type="Animation" id="Animation_y5bt0"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Button:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, 0.750413, 0)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_um1vs"] [sub_resource type="AnimationLibrary" id="AnimationLibrary_um1vs"]
_data = { _data = {
"RESET": SubResource("Animation_y5bt0"), "RESET": SubResource("Animation_y5bt0"),
@@ -63,7 +63,7 @@ _data = {
} }
[node name="ButtonStand" type="StaticBody3D"] [node name="ButtonStand" type="StaticBody3D"]
script = ExtResource("1_uieqm") script = ExtResource("1_gkcm2")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] [node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("CylinderShape3D_jpuiw") shape = SubResource("CylinderShape3D_jpuiw")

View File

@@ -1,11 +1,27 @@
[gd_scene load_steps=4 format=3 uid="uid://gg5ph541e4p3"] [gd_scene load_steps=8 format=3 uid="uid://gg5ph541e4p3"]
[ext_resource type="Script" path="res://scripts/player.gd" id="1_8d33x"] [ext_resource type="Script" path="res://scripts/player.gd" id="1_8d33x"]
[ext_resource type="PackedScene" uid="uid://cl6gw3huejnrl" path="res://scenes/gravity_gun.tscn" id="2_ahuce"] [ext_resource type="PackedScene" uid="uid://cl6gw3huejnrl" path="res://scenes/gravity_gun.tscn" id="2_ahuce"]
[ext_resource type="Script" path="res://shaders/gdscript_assist/ddof.gd" id="2_jg7te"]
[ext_resource type="Shader" path="res://shaders/ddof.gdshader" id="2_rpqdy"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_2qx4s"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_2qx4s"]
height = 1.9 height = 1.9
[sub_resource type="ShaderMaterial" id="ShaderMaterial_52bjo"]
render_priority = 0
shader = ExtResource("2_rpqdy")
shader_parameter/ray_position = null
shader_parameter/blur_strength = 3
shader_parameter/blur_falloff = 7.0
shader_parameter/blur_near = 20.0
shader_parameter/blur_far = 200.0
[sub_resource type="QuadMesh" id="QuadMesh_dicpk"]
material = SubResource("ShaderMaterial_52bjo")
flip_faces = true
size = Vector2(2, 2)
[node name="Player" type="CharacterBody3D"] [node name="Player" type="CharacterBody3D"]
script = ExtResource("1_8d33x") script = ExtResource("1_8d33x")
@@ -16,6 +32,12 @@ shape = SubResource("CapsuleShape3D_2qx4s")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0)
current = true current = true
[node name="DDOF" type="MeshInstance3D" parent="Camera3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1)
visible = false
mesh = SubResource("QuadMesh_dicpk")
script = ExtResource("2_jg7te")
[node name="GravityGun" parent="." instance=ExtResource("2_ahuce")] [node name="GravityGun" parent="." instance=ExtResource("2_ahuce")]
[editable path="GravityGun"] [editable path="GravityGun"]

View File

@@ -0,0 +1,16 @@
extends Node
signal unlock
@export var nodes_needed: Array[Completer]
var uncompleted: int
func _ready():
uncompleted = nodes_needed.size()
for node in nodes_needed:
node.completed.connect(complete)
func complete():
uncompleted -= 1
if uncompleted == 0:
unlock.emit()

5
scripts/door.gd Normal file
View File

@@ -0,0 +1,5 @@
extends Node3D
@onready var anim: AnimationPlayer = $AnimationPlayer
func open(): anim.play("open")

View File

@@ -1,6 +1,7 @@
extends StaticBody3D extends Completer
@onready var animation_player: AnimationPlayer = $AnimationPlayer @onready var animation_player: AnimationPlayer = $AnimationPlayer
func _on_interaction_area_interacted(): func _on_interaction_area_interacted():
animation_player.play("press") animation_player.play("press")
completed.emit()

View File

@@ -0,0 +1,4 @@
extends Node
class_name Completer
signal completed

View File

@@ -15,6 +15,7 @@ var camera_senitivity: float = 0.5
func _ready() -> void: func _ready() -> void:
capture() capture()
camera.make_current() camera.make_current()
$Camera3D/DDOF.show() # Würde den spieler im editor unsichtbar machen
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
gun_cam.transform = camera.transform gun_cam.transform = camera.transform

51
shaders/ddof.gdshader Normal file
View File

@@ -0,0 +1,51 @@
shader_type spatial;
render_mode unshaded, cull_back;
uniform vec3 ray_position;
uniform int blur_strength: hint_range(1,8) = 3;
uniform float blur_falloff: hint_range(1.0, 20.0) = 7.0;
uniform float blur_near: hint_range(0.0, 100.0) = 20.0;
uniform float blur_far: hint_range(0.0, 250.0) = 200.0;
uniform sampler2D depth_texture : source_color, hint_depth_texture, filter_linear;
uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_linear;
void vertex() {
POSITION = vec4(VERTEX, 1.0);
}
// Configurable Box Blur by Nighteyes -> https://godotshaders.com/shader/configurable-box-blur/
vec3 blur_size(sampler2D tex,vec2 uv, vec2 pixelSize) {
vec2 pixel = uv / pixelSize;
int x_min = max(int(pixel.x) - blur_strength, 0);
int y_min = max(int(pixel.y) - blur_strength, 0);
int x_max = min(int(pixel.x) + blur_strength, int(1.0 / pixelSize.x));
int y_max = min(int(pixel.y) + blur_strength, int(1.0 / pixelSize.y));
int count = 0;
vec3 color = vec3(0.0);
for(int x = x_min; x <= x_max; x++) {
for(int y = y_min; y <= y_max; y++) {
color += texture(tex, vec2(float(x), float(y)) * pixelSize).rgb;
count++;
}
}
return color / float(count);
}
void fragment() {
float dist = distance(CAMERA_POSITION_WORLD, ray_position);
float depth = texture(depth_texture, SCREEN_UV).r;
depth = depth * 2.0 - 1.0;
float z = -PROJECTION_MATRIX[3][2] / (depth + PROJECTION_MATRIX[2][2]);
z = z + dist/2.0;
// Calculate clear/blur threshold
float w = dist/blur_falloff;
float dz = dist >= blur_far ? 1.0 : (1.0 - smoothstep(0.001, w, -(z + w)));
dz *= dist <= blur_near ? 1.0 : smoothstep(0.001, w, -(z - w));
vec3 screen = texture(screen_texture, SCREEN_UV).rgb;
vec3 blur = blur_size(screen_texture, SCREEN_UV, 1.0/VIEWPORT_SIZE);
ALBEDO = mix(blur, screen, dz);
}

View File

@@ -0,0 +1,15 @@
extends MeshInstance3D
var DOF_LENGTH = 250;
var COLLISION_MASK = 1;
func _physics_process(_delta):
var end = global_position - global_transform.basis.z * DOF_LENGTH
var rayParams = PhysicsRayQueryParameters3D.create(global_position, end, COLLISION_MASK)
var ray = get_world_3d().direct_space_state.intersect_ray(rayParams)
if !ray.is_empty():
end = ray["position"]
var sm = get_active_material(0) as ShaderMaterial
sm.set_shader_parameter("ray_position", end)