keys and doors working
This commit is contained in:
@@ -83,7 +83,7 @@ size = Vector3(2.10059, 1.23395, 0.909241)
|
||||
|
||||
[node name="Boombox" type="RigidBody3D" groups=["breakable", "interact", "scene_rigidbody"]]
|
||||
collision_layer = 32
|
||||
collision_mask = 125
|
||||
collision_mask = 109
|
||||
continuous_cd = true
|
||||
script = ExtResource("1_ccqda")
|
||||
broken_object = ExtResource("2_26e0l")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=7 format=4 uid="uid://dqnb5y6p04lpi"]
|
||||
[gd_scene load_steps=6 format=4 uid="uid://dqnb5y6p04lpi"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/key_pickup.gd" id="1_rbnu5"]
|
||||
|
||||
@@ -8,7 +8,6 @@ cull_mode = 2
|
||||
albedo_color = Color(0.671507, 0.697251, 0.673335, 1)
|
||||
metallic = 1.0
|
||||
roughness = 0.0898204
|
||||
emission_enabled = true
|
||||
emission = Color(1, 1, 1, 1)
|
||||
emission_energy_multiplier = 0.1
|
||||
|
||||
@@ -49,15 +48,12 @@ shadow_mesh = SubResource("ArrayMesh_crfbj")
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_0gdfr"]
|
||||
size = Vector3(0.913818, 0.10791, 0.37793)
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_vujtd"]
|
||||
radius = 1.26183
|
||||
|
||||
[node name="Key1" type="RigidBody3D" node_paths=PackedStringArray("collision_shape") groups=["scene_rigidbody"]]
|
||||
collision_layer = 0
|
||||
collision_mask = 33
|
||||
[node name="Key1" type="RigidBody3D" node_paths=PackedStringArray("collision_shape") groups=["magnet", "pickup", "scene_rigidbody"]]
|
||||
collision_layer = 16
|
||||
collision_mask = 49
|
||||
continuous_cd = true
|
||||
script = ExtResource("1_rbnu5")
|
||||
collision_shape = NodePath("Area3D")
|
||||
collision_shape = NodePath("CollisionShape3D")
|
||||
|
||||
[node name="Key" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(0.92388, 0, 0.382683, 0, 1, 0, -0.382683, 0, 0.92388, 0.0247749, 0, 0)
|
||||
@@ -67,10 +63,3 @@ skeleton = NodePath("")
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0285698, -0.00170898, -0.0102517)
|
||||
shape = SubResource("BoxShape3D_0gdfr")
|
||||
|
||||
[node name="Area3D" type="Area3D" parent="."]
|
||||
collision_layer = 16
|
||||
collision_mask = 16
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
|
||||
shape = SubResource("SphereShape3D_vujtd")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=39 format=4 uid="uid://ddyfy6iosbgsj"]
|
||||
[gd_scene load_steps=47 format=4 uid="uid://ddyfy6iosbgsj"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/LevelManager.gd" id="1_jjeos"]
|
||||
[ext_resource type="PackedScene" uid="uid://b5eclfg0cmmal" path="res://assets/revolver_1.tscn" id="2_7dd4i"]
|
||||
@@ -9,7 +9,7 @@
|
||||
[ext_resource type="Material" uid="uid://buv88wwtgorlx" path="res://assets/materials/prototype/mulch.tres" id="6_kw162"]
|
||||
[ext_resource type="PackedScene" uid="uid://drwae3loscbw7" path="res://assets/player.tscn" id="6_m8xxf"]
|
||||
[ext_resource type="PackedScene" uid="uid://20csd6dmwj4y" path="res://assets/jump_platform.tscn" id="8_grlcd"]
|
||||
[ext_resource type="Script" path="res://scripts/door.gd" id="10_08mbs"]
|
||||
[ext_resource type="Script" path="res://scripts/switch_door.gd" id="10_08mbs"]
|
||||
[ext_resource type="PackedScene" uid="uid://dy6uywh1duwxy" path="res://assets/switch.tscn" id="10_lktr8"]
|
||||
[ext_resource type="Script" path="res://levels/switchcontroller.gd" id="11_wstss"]
|
||||
[ext_resource type="Script" path="res://scripts/switch_interactandshoot.gd" id="12_yaq57"]
|
||||
@@ -18,6 +18,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://chr8q10bxnrsa" path="res://assets/pressure_plate.tscn" id="15_e5ppe"]
|
||||
[ext_resource type="PackedScene" uid="uid://cnfc8rtk6l1d8" path="res://assets/crate1.tscn" id="16_cda17"]
|
||||
[ext_resource type="PackedScene" uid="uid://dqnb5y6p04lpi" path="res://assets/key_1.tscn" id="18_ya2eo"]
|
||||
[ext_resource type="Script" path="res://scripts/key_door.gd" id="19_fiwww"]
|
||||
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_y04oh"]
|
||||
sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
|
||||
@@ -279,6 +280,67 @@ _data = {
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_vyys8"]
|
||||
radius = 0.505049
|
||||
|
||||
[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_rdueq"]
|
||||
data = PackedVector3Array(-2.375, 3.4025, 0.125, 2.375, 3.4025, 0.125, -2.375, -3.4025, 0.125, 2.375, 3.4025, 0.125, 2.375, -3.4025, 0.125, -2.375, -3.4025, 0.125, 2.375, 3.4025, -0.125, -2.375, 3.4025, -0.125, 2.375, -3.4025, -0.125, -2.375, 3.4025, -0.125, -2.375, -3.4025, -0.125, 2.375, -3.4025, -0.125, 2.375, 3.4025, 0.125, 2.375, 3.4025, -0.125, 2.375, -3.4025, 0.125, 2.375, 3.4025, -0.125, 2.375, -3.4025, -0.125, 2.375, -3.4025, 0.125, -2.375, 3.4025, -0.125, -2.375, 3.4025, 0.125, -2.375, -3.4025, -0.125, -2.375, 3.4025, 0.125, -2.375, -3.4025, 0.125, -2.375, -3.4025, -0.125, 2.375, 3.4025, 0.125, -2.375, 3.4025, 0.125, 2.375, 3.4025, -0.125, -2.375, 3.4025, 0.125, -2.375, 3.4025, -0.125, 2.375, 3.4025, -0.125, -2.375, -3.4025, 0.125, 2.375, -3.4025, 0.125, -2.375, -3.4025, -0.125, 2.375, -3.4025, 0.125, 2.375, -3.4025, -0.125, -2.375, -3.4025, -0.125)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_fd2rc"]
|
||||
size = Vector3(4.75, 6.805, 0.25)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_jmej3"]
|
||||
resource_name = "open"
|
||||
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, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(4.43091, 3.29403, -50.9568), Vector3(4.43091, 9.85387, -50.9568)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_w5uyq"]
|
||||
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(4.43091, 3.29403, -50.9568)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_12hts"]
|
||||
resource_name = "close"
|
||||
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, 1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector3(4.43091, 9.85387, -50.9568), Vector3(4.43091, 3.29403, -50.9568)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_pobrj"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_w5uyq"),
|
||||
"close": SubResource("Animation_12hts"),
|
||||
"open": SubResource("Animation_jmej3")
|
||||
}
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_4andu"]
|
||||
size = Vector3(5.505, 7.07, 1.35)
|
||||
|
||||
[node name="Blockout3" type="Node3D" node_paths=PackedStringArray("player")]
|
||||
script = ExtResource("1_jjeos")
|
||||
player = NodePath("Player")
|
||||
@@ -346,7 +408,6 @@ gi_mode = 2
|
||||
mesh = SubResource("BoxMesh_6no40")
|
||||
script = ExtResource("10_08mbs")
|
||||
anim_player = NodePath("AnimationPlayer")
|
||||
door_open_start = true
|
||||
|
||||
[node name="StaticBody3D2" type="StaticBody3D" parent="Door1/Door"]
|
||||
|
||||
@@ -420,6 +481,35 @@ omni_range = 16.0131
|
||||
[node name="Key1" parent="." instance=ExtResource("18_ya2eo")]
|
||||
transform = Transform3D(1, 0, 0, 0, -0.0228967, -0.999738, 0, 0.999738, -0.0228967, 1.65768, 0.706259, -36.9888)
|
||||
|
||||
[node name="Door2" type="Node" parent="."]
|
||||
|
||||
[node name="Door" type="AnimatableBody3D" parent="Door2" node_paths=PackedStringArray("anim_player")]
|
||||
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 4.43091, 3.29403, -50.9568)
|
||||
script = ExtResource("19_fiwww")
|
||||
anim_player = NodePath("AnimationPlayer")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Door2/Door"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.38419e-07, -1.90735e-06)
|
||||
shape = SubResource("ConcavePolygonShape3D_rdueq")
|
||||
|
||||
[node name="Door" type="MeshInstance3D" parent="Door2/Door"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00479889, -0.0307367, -0.0134363)
|
||||
mesh = SubResource("BoxMesh_fd2rc")
|
||||
skeleton = NodePath("../..")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="Door2/Door"]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_pobrj")
|
||||
}
|
||||
|
||||
[node name="InteractArea" type="Area3D" parent="Door2/Door" groups=["interact"]]
|
||||
collision_layer = 2
|
||||
collision_mask = 2
|
||||
|
||||
[node name="CollisionShape3D2" type="CollisionShape3D" parent="Door2/Door/InteractArea"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.38419e-07, -1.90735e-06)
|
||||
shape = SubResource("BoxShape3D_4andu")
|
||||
|
||||
[connection signal="switch_hit" from="Door1/switch/StaticBody3D" to="Door1/switch" method="_on_static_body_3d_switch_hit"]
|
||||
[connection signal="switch_hit" from="Door1/switch2/StaticBody3D" to="Door1/switch2" method="_on_static_body_3d_switch_hit"]
|
||||
[connection signal="switch_hit" from="Door1/switch3/StaticBody3D" to="Door1/switch3" method="_on_static_body_3d_switch_hit"]
|
||||
|
||||
@@ -11,7 +11,7 @@ config_version=5
|
||||
[application]
|
||||
|
||||
config/name="First Person Test"
|
||||
run/main_scene="res://assets/blockout_2.tscn"
|
||||
run/main_scene="res://levels/blockout_3.tscn"
|
||||
config/features=PackedStringArray("4.3", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
@@ -40,6 +40,7 @@ switch=""
|
||||
scene_rigidbody=""
|
||||
weight=""
|
||||
switch_override=""
|
||||
magnet=""
|
||||
|
||||
[input]
|
||||
|
||||
|
||||
47
scripts/key_door.gd
Normal file
47
scripts/key_door.gd
Normal file
@@ -0,0 +1,47 @@
|
||||
extends Node3D
|
||||
|
||||
@onready var level_control = get_tree().current_scene
|
||||
|
||||
@export var anim_player : Node
|
||||
@export var door_open_start : bool = false
|
||||
@export_enum("Silver", "Gold", "Special") var key_type_required: int
|
||||
@export var special_key_name : String
|
||||
|
||||
var door_open : bool
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
door_open = door_open_start
|
||||
|
||||
if door_open:
|
||||
open()
|
||||
else:
|
||||
close()
|
||||
|
||||
func open():
|
||||
door_open = true
|
||||
anim_player.play("open")
|
||||
|
||||
func close():
|
||||
door_open = false
|
||||
anim_player.play("close")
|
||||
|
||||
func interact():
|
||||
if !door_open:
|
||||
print("checking keys..." + str(level_control.keys))
|
||||
|
||||
var exit = false
|
||||
|
||||
for i in level_control.keys:
|
||||
if !exit:
|
||||
if i[0] == key_type_required:
|
||||
if key_type_required == 2:
|
||||
if i[1] == special_key_name:
|
||||
open()
|
||||
level_control.keys.erase(i)
|
||||
exit = true
|
||||
else:
|
||||
open()
|
||||
level_control.keys.erase(i)
|
||||
exit = true
|
||||
@@ -4,16 +4,36 @@ extends RigidBody3D
|
||||
@export var special_key_name : String
|
||||
@export var collision_shape : Node
|
||||
|
||||
@onready var level_control = get_tree().current_scene
|
||||
@onready var player = get_tree().current_scene.player
|
||||
|
||||
var pickupable = true
|
||||
var pick_up = false
|
||||
var rand_amt
|
||||
var player_follow
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
|
||||
add_to_group("pickup")
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
func _physics_process(delta: float) -> void:
|
||||
if player_follow != null:
|
||||
if !pick_up:
|
||||
angular_velocity = lerp(angular_velocity, Vector3(0,0,0), delta)
|
||||
position = lerp(position, player.item_holder.global_position, 25 * delta)
|
||||
|
||||
if abs(position - player.item_holder.global_position) < Vector3(.5,.5,.5):
|
||||
await get_tree().create_timer(1).timeout
|
||||
position = lerp(position, player.camera.global_position, .01 * delta)
|
||||
await get_tree().create_timer(.01).timeout
|
||||
picked_up()
|
||||
|
||||
func picked_up():
|
||||
pass
|
||||
var key_attributes = [key_type, special_key_name]
|
||||
level_control.keys.append(key_attributes)
|
||||
print(level_control.keys)
|
||||
queue_free()
|
||||
|
||||
@@ -159,6 +159,7 @@ func _physics_process(delta):
|
||||
air_dash -= 1
|
||||
print("AIR DASH " +str(air_dash))
|
||||
|
||||
#walking
|
||||
if is_on_floor() and !is_climbing:
|
||||
if direction:
|
||||
velocity.x = lerp(velocity.x, direction.x * speed, delta * WALK_TRANSITION_SPEED)
|
||||
@@ -166,6 +167,7 @@ func _physics_process(delta):
|
||||
else:
|
||||
velocity.x = lerp(velocity.x, direction.x * speed, delta * 6.5) + (direction.x * DASH_SPEED)
|
||||
velocity.z = lerp(velocity.z, direction.z * speed, delta * 6.5) + (direction.z * DASH_SPEED)
|
||||
#ladder movement
|
||||
elif is_climbing:
|
||||
gravity = 0.0
|
||||
if direction:
|
||||
@@ -174,9 +176,10 @@ func _physics_process(delta):
|
||||
else:
|
||||
velocity.y = lerp(velocity.y, -direction.z * speed, delta * 6.5)
|
||||
velocity.x = lerp(velocity.x, direction.x * speed, delta * 6.5)
|
||||
#movement in air
|
||||
else:
|
||||
velocity.x = lerp(velocity.x, direction.x * speed, delta * 6.5)
|
||||
velocity.z = lerp(velocity.z, direction.z * speed, delta * 6.5)
|
||||
velocity.x = lerp(velocity.x, direction.x * speed, delta * 3)
|
||||
velocity.z = lerp(velocity.z, direction.z * speed, delta * 3)
|
||||
|
||||
# Head bob
|
||||
t_bob += delta * velocity.length() * float(is_on_floor())
|
||||
|
||||
Reference in New Issue
Block a user