key functionality + doors
This commit is contained in:
parent
09ae350b9e
commit
6a0e9f791b
@ -3,6 +3,8 @@ extends KinematicBody
|
||||
# export variables
|
||||
export(NodePath) var body_nodepath
|
||||
export(NodePath) var lookingAt_nodepath
|
||||
export(int) var keycard_lvl
|
||||
export(Array) var key_chain
|
||||
|
||||
# const
|
||||
const GRAVITY = -24.8
|
||||
@ -12,7 +14,7 @@ const SPRINT_SPEED = 40
|
||||
const ACCEL = 4.5
|
||||
const MAX_SLOPE_ANGLE = 40
|
||||
const MOUSE_SENSITIVITY = 0.05
|
||||
const INTERACT_DISTANCE = 5
|
||||
const INTERACT_DISTANCE = 4
|
||||
|
||||
# private members
|
||||
var _body: Spatial
|
||||
@ -91,8 +93,8 @@ func process_movement(delta):
|
||||
func check_interact():
|
||||
if _lookCast.is_colliding():
|
||||
var collider = _lookCast.get_collider()
|
||||
if "being_touched" in collider:
|
||||
collider.being_touched = true
|
||||
if collider.is_in_group("Touchables") :
|
||||
collider.do_interact(self)
|
||||
|
||||
func _input(event):
|
||||
# capture mouse movement
|
||||
|
@ -89,10 +89,21 @@ group_name = "Navigator"
|
||||
node_to_send = NodePath("..")
|
||||
|
||||
[node name="Key" parent="." instance=ExtResource( 5 )]
|
||||
transform = Transform( 0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, -6.89502, 0.788358, 9.21277 )
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -6.8315, 0.73042, 8.99112 )
|
||||
key_id = 1
|
||||
|
||||
[node name="Keycard" parent="." instance=ExtResource( 6 )]
|
||||
transform = Transform( 0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, -6.88316, 0.705314, 8.68398 )
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -6.84089, 0.700821, 8.67166 )
|
||||
card_lvl = 1
|
||||
|
||||
[node name="Door" parent="." instance=ExtResource( 7 )]
|
||||
transform = Transform( -2.18557e-008, 0, 0.5, 0, 0.5, 0, -0.5, 0, -2.18557e-008, -10, 1, 10 )
|
||||
|
||||
[node name="Door2" parent="." instance=ExtResource( 7 )]
|
||||
transform = Transform( -2.18557e-008, 0, 0.5, 0, 0.5, 0, -0.5, 0, -2.18557e-008, -10, 1, 8 )
|
||||
door_id = 1
|
||||
|
||||
[node name="Door3" parent="." instance=ExtResource( 7 )]
|
||||
transform = Transform( -2.18557e-008, 0, 0.5, 0, 0.5, 0, -0.5, 0, -2.18557e-008, -10, 1, 6 )
|
||||
card_door = true
|
||||
door_id = 1
|
||||
|
@ -1,7 +1,8 @@
|
||||
extends KinematicBody
|
||||
|
||||
# export variables
|
||||
export(bool) var being_touched
|
||||
export(bool) var card_door
|
||||
export(int) var door_id
|
||||
|
||||
# const
|
||||
const OPENING_SPEED = 50
|
||||
@ -18,16 +19,25 @@ func _ready():
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
#if Input.is_action_just_pressed("interact"):
|
||||
if being_touched:
|
||||
if _isMoving:
|
||||
door_move(delta)
|
||||
|
||||
# called by player to interact with this scene
|
||||
func do_interact(var player):
|
||||
if card_door:
|
||||
if player.keycard_lvl >= door_id:
|
||||
_isMoving = true
|
||||
_isOpening = !_isOpening
|
||||
else:
|
||||
print("keycard level too low")
|
||||
elif player.key_chain.has(door_id) or door_id == 0:
|
||||
_isMoving = true
|
||||
_isOpening = !_isOpening
|
||||
being_touched = false
|
||||
|
||||
if _isMoving:
|
||||
doorMove(delta)
|
||||
|
||||
func doorMove(delta):
|
||||
else:
|
||||
print("you don't have the right key")
|
||||
|
||||
# opens or closes the door
|
||||
func door_move(delta):
|
||||
if _isOpening:
|
||||
if _degrees < 100:
|
||||
_degrees += OPENING_SPEED * delta
|
||||
|
@ -8,7 +8,9 @@
|
||||
|
||||
[sub_resource type="BoxShape" id=3]
|
||||
|
||||
[node name="Door" type="KinematicBody"]
|
||||
[node name="Door" type="KinematicBody" groups=[
|
||||
"Touchables",
|
||||
]]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="DoorMesh" type="MeshInstance" parent="."]
|
||||
|
16
Things/Key/Key.gd
Normal file
16
Things/Key/Key.gd
Normal file
@ -0,0 +1,16 @@
|
||||
extends StaticBody
|
||||
|
||||
# export variables
|
||||
export(int) var key_id
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
func do_interact(var player):
|
||||
player.key_chain.append(key_id)
|
||||
queue_free()
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
File diff suppressed because one or more lines are too long
16
Things/Keycard/Keycard.gd
Normal file
16
Things/Keycard/Keycard.gd
Normal file
@ -0,0 +1,16 @@
|
||||
extends StaticBody
|
||||
|
||||
# export variables
|
||||
export(int) var card_lvl
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
func do_interact(var player):
|
||||
player.keycard_lvl = card_lvl
|
||||
queue_free()
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
@ -1,44 +1,18 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://Models/keycard/keycard.dae" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Models/keycard/Material_002.material" type="Material" id=2]
|
||||
[ext_resource path="res://Models/keycard/Material.material" type="Material" id=3]
|
||||
[ext_resource path="res://Things/Keycard/Keycard.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Models/keycard/keycard.dae" type="PackedScene" id=2]
|
||||
|
||||
[sub_resource type="ArrayMesh" id=1]
|
||||
resource_name = "Cube"
|
||||
surfaces/0 = {
|
||||
"aabb": AABB( 1, -1, -1, 1.00136e-005, 2, 2.00001 ),
|
||||
"array_data": PoolByteArray( 0, 0, 128, 63, 205, 204, 76, 191, 0, 0, 128, 63, 127, 0, 0, 0, 0, 0, 129, 127, 0, 0, 51, 59, 0, 0, 128, 63, 0, 0, 128, 191, 129, 202, 89, 63, 127, 0, 0, 0, 0, 0, 129, 127, 198, 44, 0, 60, 0, 0, 128, 63, 0, 0, 128, 191, 154, 153, 89, 191, 127, 0, 0, 0, 0, 0, 129, 127, 102, 59, 0, 60, 0, 0, 128, 63, 205, 204, 76, 191, 0, 0, 128, 191, 127, 0, 0, 0, 0, 0, 129, 127, 0, 60, 51, 59, 0, 0, 128, 63, 205, 204, 76, 63, 0, 0, 128, 191, 127, 0, 0, 0, 0, 0, 130, 127, 0, 60, 102, 46, 0, 0, 128, 63, 0, 0, 128, 63, 154, 153, 89, 191, 127, 0, 0, 0, 0, 0, 129, 127, 102, 59, 0, 0, 0, 0, 128, 63, 0, 0, 128, 63, 154, 153, 89, 63, 127, 0, 0, 0, 0, 0, 129, 127, 204, 44, 0, 0, 0, 0, 128, 63, 205, 204, 76, 63, 0, 0, 128, 63, 127, 0, 0, 0, 0, 0, 129, 127, 0, 0, 102, 46 ),
|
||||
"array_index_data": PoolByteArray( 0, 0, 2, 0, 1, 0, 2, 0, 0, 0, 3, 0, 3, 0, 0, 0, 4, 0, 4, 0, 6, 0, 5, 0, 6, 0, 4, 0, 7, 0, 7, 0, 4, 0, 0, 0 ),
|
||||
"blend_shape_data": [ ],
|
||||
"format": 97559,
|
||||
"index_count": 18,
|
||||
"material": ExtResource( 2 ),
|
||||
"name": "Material.002",
|
||||
"primitive": 4,
|
||||
"skeleton_aabb": [ ],
|
||||
"vertex_count": 8
|
||||
}
|
||||
surfaces/1 = {
|
||||
"aabb": AABB( -1, -1, -1, 2.00001, 2.00001, 2 ),
|
||||
"array_data": PoolByteArray( 0, 0, 128, 63, 0, 0, 128, 63, 154, 153, 89, 63, 0, 127, 0, 0, 127, 0, 0, 127, 0, 0, 0, 60, 0, 0, 128, 191, 0, 0, 128, 63, 154, 153, 89, 191, 0, 127, 0, 0, 127, 0, 0, 127, 0, 0, 0, 60, 0, 0, 128, 191, 0, 0, 128, 63, 154, 153, 89, 63, 0, 127, 0, 0, 127, 0, 0, 127, 0, 0, 0, 60, 0, 0, 128, 63, 205, 204, 76, 63, 0, 0, 128, 63, 0, 76, 101, 0, 126, 250, 4, 129, 0, 57, 0, 58, 0, 0, 128, 191, 0, 0, 128, 63, 154, 153, 89, 63, 0, 76, 101, 0, 126, 250, 4, 129, 0, 0, 0, 60, 0, 0, 128, 191, 205, 204, 76, 63, 0, 0, 128, 63, 0, 76, 101, 0, 126, 250, 4, 129, 0, 57, 0, 56, 0, 0, 128, 63, 205, 204, 76, 191, 0, 0, 128, 63, 0, 0, 127, 0, 99, 79, 0, 127, 0, 0, 0, 60, 0, 0, 128, 191, 205, 204, 76, 63, 0, 0, 128, 63, 0, 0, 127, 0, 99, 79, 0, 127, 0, 57, 0, 56, 0, 0, 128, 191, 205, 204, 76, 191, 0, 0, 128, 63, 0, 0, 127, 0, 127, 0, 0, 129, 0, 0, 0, 60, 0, 0, 128, 191, 205, 204, 76, 191, 0, 0, 128, 191, 0, 0, 129, 0, 127, 0, 0, 127, 0, 54, 0, 52, 0, 0, 128, 63, 205, 204, 76, 63, 0, 0, 128, 191, 0, 0, 129, 0, 127, 0, 0, 127, 0, 0, 0, 60, 0, 0, 128, 63, 205, 204, 76, 191, 0, 0, 128, 191, 0, 0, 129, 0, 127, 0, 0, 127, 0, 57, 0, 52, 0, 0, 128, 63, 0, 0, 128, 63, 154, 153, 89, 191, 0, 76, 155, 0, 127, 0, 0, 127, 0, 0, 0, 60, 0, 0, 128, 191, 205, 204, 76, 63, 0, 0, 128, 191, 0, 76, 155, 0, 127, 0, 0, 127, 0, 0, 0, 60, 0, 0, 128, 191, 0, 0, 128, 63, 154, 153, 89, 191, 0, 76, 155, 0, 127, 0, 0, 127, 0, 0, 0, 60, 0, 0, 128, 63, 205, 204, 76, 191, 0, 0, 128, 191, 0, 180, 155, 0, 125, 14, 246, 129, 0, 57, 0, 52, 0, 0, 128, 191, 0, 0, 128, 191, 154, 153, 89, 191, 0, 180, 155, 0, 125, 14, 246, 129, 0, 54, 104, 48, 0, 0, 128, 191, 205, 204, 76, 191, 0, 0, 128, 191, 0, 180, 155, 0, 127, 0, 0, 127, 0, 54, 0, 52, 0, 0, 128, 63, 0, 0, 128, 191, 129, 202, 89, 63, 0, 180, 101, 0, 126, 0, 0, 129, 0, 57, 117, 38, 0, 0, 128, 191, 205, 204, 76, 191, 0, 0, 128, 63, 0, 180, 101, 0, 126, 0, 0, 129, 0, 0, 0, 60, 0, 0, 128, 191, 0, 0, 128, 191, 178, 104, 89, 63, 0, 180, 101, 0, 126, 0, 0, 129, 0, 54, 130, 38, 0, 0, 128, 191, 0, 0, 128, 191, 178, 104, 89, 63, 0, 129, 0, 0, 237, 0, 131, 129, 0, 54, 130, 38, 0, 0, 128, 63, 0, 0, 128, 191, 154, 153, 89, 191, 0, 129, 0, 0, 237, 0, 131, 129, 0, 0, 0, 60, 0, 0, 128, 63, 0, 0, 128, 191, 129, 202, 89, 63, 0, 129, 0, 0, 126, 0, 0, 127, 0, 57, 117, 38, 0, 0, 128, 191, 205, 204, 76, 191, 0, 0, 128, 191, 129, 0, 0, 0, 0, 59, 112, 129, 0, 54, 0, 52, 0, 0, 128, 191, 0, 0, 128, 191, 154, 153, 89, 191, 129, 0, 0, 0, 127, 0, 0, 127, 0, 54, 104, 48, 0, 0, 128, 191, 0, 0, 128, 191, 178, 104, 89, 63, 129, 0, 0, 0, 0, 10, 130, 127, 0, 54, 130, 38, 0, 0, 128, 63, 0, 0, 128, 63, 154, 153, 89, 191, 0, 127, 0, 0, 127, 0, 0, 127, 0, 0, 0, 60, 0, 0, 128, 63, 0, 0, 128, 63, 154, 153, 89, 63, 0, 76, 101, 0, 127, 0, 0, 129, 0, 0, 0, 60, 0, 0, 128, 63, 205, 204, 76, 63, 0, 0, 128, 63, 0, 0, 127, 0, 99, 79, 0, 127, 0, 57, 0, 58, 0, 0, 128, 191, 205, 204, 76, 63, 0, 0, 128, 191, 0, 0, 129, 0, 127, 0, 0, 127, 0, 0, 0, 60, 0, 0, 128, 63, 205, 204, 76, 63, 0, 0, 128, 191, 0, 76, 155, 0, 127, 0, 0, 127, 0, 0, 0, 60, 0, 0, 128, 63, 0, 0, 128, 191, 154, 153, 89, 191, 0, 180, 155, 0, 125, 14, 246, 129, 0, 0, 0, 60, 0, 0, 128, 63, 0, 0, 128, 191, 129, 202, 89, 63, 0, 181, 101, 0, 127, 0, 0, 129, 0, 57, 117, 38, 0, 0, 128, 63, 205, 204, 76, 191, 0, 0, 128, 63, 0, 181, 101, 0, 127, 0, 0, 129, 0, 0, 0, 60, 0, 0, 128, 191, 205, 204, 76, 191, 0, 0, 128, 63, 0, 181, 101, 0, 127, 0, 0, 129, 0, 0, 0, 60, 0, 0, 128, 191, 0, 0, 128, 191, 154, 153, 89, 191, 0, 129, 0, 0, 237, 0, 131, 129, 0, 54, 104, 48, 0, 0, 128, 191, 205, 204, 76, 191, 0, 0, 128, 63, 129, 0, 0, 0, 0, 126, 8, 127, 0, 0, 0, 60, 0, 0, 128, 191, 205, 204, 76, 63, 0, 0, 128, 63, 129, 0, 0, 0, 0, 59, 112, 129, 0, 57, 0, 56, 0, 0, 128, 191, 0, 0, 128, 63, 154, 153, 89, 63, 129, 0, 0, 0, 127, 0, 0, 127, 0, 0, 0, 60, 0, 0, 128, 191, 0, 0, 128, 63, 154, 153, 89, 191, 129, 0, 0, 0, 127, 0, 0, 127, 0, 0, 0, 60, 0, 0, 128, 191, 205, 204, 76, 63, 0, 0, 128, 191, 129, 0, 0, 0, 0, 59, 112, 129, 0, 0, 0, 60 ),
|
||||
"array_index_data": PoolByteArray( 0, 0, 2, 0, 1, 0, 3, 0, 5, 0, 4, 0, 6, 0, 8, 0, 7, 0, 9, 0, 11, 0, 10, 0, 12, 0, 14, 0, 13, 0, 15, 0, 17, 0, 16, 0, 18, 0, 20, 0, 19, 0, 21, 0, 23, 0, 22, 0, 24, 0, 26, 0, 25, 0, 0, 0, 1, 0, 27, 0, 3, 0, 4, 0, 28, 0, 6, 0, 7, 0, 29, 0, 9, 0, 10, 0, 30, 0, 12, 0, 13, 0, 31, 0, 15, 0, 16, 0, 32, 0, 33, 0, 35, 0, 34, 0, 21, 0, 22, 0, 36, 0, 26, 0, 24, 0, 37, 0, 37, 0, 24, 0, 38, 0, 38, 0, 40, 0, 39, 0, 40, 0, 38, 0, 41, 0, 41, 0, 38, 0, 24, 0 ),
|
||||
"blend_shape_data": [ ],
|
||||
"format": 97559,
|
||||
"index_count": 66,
|
||||
"material": ExtResource( 3 ),
|
||||
"name": "Material",
|
||||
"primitive": 4,
|
||||
"skeleton_aabb": [ ],
|
||||
"vertex_count": 42
|
||||
}
|
||||
[sub_resource type="BoxShape" id=1]
|
||||
|
||||
[node name="Keycard" instance=ExtResource( 1 )]
|
||||
[node name="Keycard" type="StaticBody" groups=[
|
||||
"Touchables",
|
||||
]]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Spatial" type="Spatial" parent="." index="0"]
|
||||
[node name="KeycardModel" parent="." instance=ExtResource( 2 )]
|
||||
transform = Transform( 0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0 )
|
||||
|
||||
[node name="Keycard" type="MeshInstance" parent="Spatial" index="0"]
|
||||
transform = Transform( 0.005, 0, 0, 0, 0.06, 0, 0, 0, 0.1, 0, 0, 0 )
|
||||
mesh = SubResource( 1 )
|
||||
material/0 = ExtResource( 2 )
|
||||
material/1 = ExtResource( 3 )
|
||||
[node name="CollisionShape" type="CollisionShape" parent="."]
|
||||
transform = Transform( 0.02, 0, 0, 0, 0.08, 0, 0, 0, 0.12, 0, 0, 0 )
|
||||
shape = SubResource( 1 )
|
||||
|
Loading…
x
Reference in New Issue
Block a user