-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollectable.gd
More file actions
49 lines (40 loc) · 1.29 KB
/
Collectable.gd
File metadata and controls
49 lines (40 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
extends MeshInstance3D
const description = "Looks like an id card. Press [E] to interact";
const outDescription = "You just picked up an id card with your \n
Name: woiuhgwergrwef \n
Date Of Birth: 05-04-1999."
var within = false;
var time = 0;
var initY = 0
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if Global.currentItem == outDescription:
Global.inspectionID = 0;
time += delta
if time > 3:
Global.transitionAlpha *= 0.9
if Global.transitionAlpha < 0.1:
Global.currentItem = ""
Global.inspectionID = -1;
queue_free()
else:
Global.transitionAlpha += (0.8 - Global.transitionAlpha) / 16
if Global.player != null:
var distance = Global.player.transform.origin.distance_to(transform.origin);
if distance < 2 and visible:
if not within:
Global.currentDescription = description;
within = true
if Input.is_action_just_pressed("E") && not Global.focused:
Global.inspecting = true;
Global.currentItem = outDescription
Global.noOfItemsCollected += 1
Global.queueOfItemsPicked.append(0)
visible = false
else:
if within:
Global.currentDescription = "";
within = false