-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDemo.gd
78 lines (61 loc) · 2.71 KB
/
Demo.gd
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
extends Spatial
export var MAX_LAPS = 10
var proper_start = false
var proper_direction = false
var lapCount = 0
func _ready():
#handle haptics - connect to each controller's pickup function and then connect it to haptic pulse function
$Player/LeftHandController/Function_Pickup.connect("has_picked_up", self, "haptic_pulse_on_pickup")
$Player/RightHandController/Function_Pickup.connect("has_picked_up", self, "haptic_pulse_on_pickup")
func haptic_pulse_on_pickup(what):
#What is passed as a parameter by the has_picked_up signal and is the object pickable, in turn that has a _by_controller property that yield the picked up controller
what.by_controller.set_rumble(0.2)
yield(get_tree().create_timer(0.2), "timeout")
what.by_controller.set_rumble(0.0)
func _on_StartingLine_area_entered(area):
if proper_start == true and proper_direction == true:
if area.collision_layer == 512:
#used for distinguishing between cars at some point, not currently used
var car_number = area.get_parent().car_number
$LapChime.play()
$CounterTimer.reset()
$CounterTimer.start()
lapCount += 1
if lapCount > MAX_LAPS:
lapCount = 1
proper_direction = false
func _update_lap_scores():
if lapCount == 1:
$Track_v2/Cylinder001/LapLabel1.text = str($CounterTimer.counter_time)
if lapCount == 2:
$Track_v2/Cylinder001/LapLabel2.text = str($CounterTimer.counter_time)
if lapCount == 3:
$Track_v2/Cylinder001/LapLabel3.text = str($CounterTimer.counter_time)
if lapCount == 4:
$Track_v2/Cylinder001/LapLabel4.text = str($CounterTimer.counter_time)
if lapCount == 5:
$Track_v2/Cylinder001/LapLabel5.text = str($CounterTimer.counter_time)
if lapCount == 6:
$Track_v2/Cylinder001/LapLabel6.text = str($CounterTimer.counter_time)
if lapCount == 7:
$Track_v2/Cylinder001/LapLabel7.text = str($CounterTimer.counter_time)
if lapCount == 8:
$Track_v2/Cylinder001/LapLabel8.text = str($CounterTimer.counter_time)
if lapCount == 9:
$Track_v2/Cylinder001/LapLabel9.text = str($CounterTimer.counter_time)
if lapCount == 10:
$Track_v2/Cylinder001/LapLabel10.text = str($CounterTimer.counter_time)
func _process(delta):
_update_lap_scores()
func _on_StartingBlock_area_exited(area):
if area.collision_layer == 512:
proper_start = true
proper_direction = true # Replace with function body.
if $StartingBlock/StartingBlockMesh.visible == true:
$StartingBlock/StartingBlockMesh.visible = false
if $StartingBlock/StartingLabel3D.visible == true:
$StartingBlock/StartingLabel3D.visible = false
func _on_VRVehicleManager_player_in_vehicle(player_node, vehicle_node):
pass# Replace with function body.
func _on_VRVehicleManager_player_left_vehicle(player_node, vehicle_node):
pass # Replace with function body.