From bbde8b2ae742a13d942cf4d495582ada437c07d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Thu, 20 Jan 2022 20:52:50 +0100 Subject: [PATCH] Add basic finish gate --- scenes/base_track_level.gd | 2 +- scenes/finish_gate.tscn | 16 ++++++++++++++++ scenes/race_condition_track_level.tscn | 1 + scenes/tracks/track.gd | 6 ++++++ scenes/tracks/track.tscn | 7 +------ 5 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 scenes/finish_gate.tscn diff --git a/scenes/base_track_level.gd b/scenes/base_track_level.gd index 1dbc37a..ed546c3 100644 --- a/scenes/base_track_level.gd +++ b/scenes/base_track_level.gd @@ -42,7 +42,7 @@ func reset_player_to(node_to_reset_to: Node, player_node: BuggedVehicle) -> void ).origin, node_to_reset_to.global_transform.basis.y ) - player_node.reset_transform.origin += node_to_reset_to.global_transform.basis.y * 3 + player_node.reset_transform.origin += node_to_reset_to.global_transform.basis.y * 2 func _spawn_in_player(): diff --git a/scenes/finish_gate.tscn b/scenes/finish_gate.tscn new file mode 100644 index 0000000..e63f900 --- /dev/null +++ b/scenes/finish_gate.tscn @@ -0,0 +1,16 @@ +[gd_scene format=2] + +[node name="Spatial" type="Spatial"] + +[node name="CSGBox" type="CSGBox" parent="."] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0 ) +width = 1.0 +height = 1.0 +depth = 1.0 + +[node name="CSGBox" type="CSGBox" parent="CSGBox"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.124099, 0 ) +operation = 2 +width = 0.8 +height = 1.10884 +depth = 1.27364 diff --git a/scenes/race_condition_track_level.tscn b/scenes/race_condition_track_level.tscn index 06d2161..8a9c4c1 100644 --- a/scenes/race_condition_track_level.tscn +++ b/scenes/race_condition_track_level.tscn @@ -72,6 +72,7 @@ albedo_color = Color( 0.203922, 0.203922, 0.203922, 1 ) [node name="Track" parent="." index="1"] track_path = NodePath("../Path") checkpoint_polygon = PoolVector2Array( -20, -4, -20, 10, 20, 10, 20, -4 ) +gate_size = Vector3( 42, 20, 5 ) [node name="Grass" type="StaticBody" parent="." index="2"] transform = Transform( 0.8, 0, 0, 0, 1, 0, 0, 0, 0.4, 0, 5, 0 ) diff --git a/scenes/tracks/track.gd b/scenes/tracks/track.gd index 512db2e..df0319d 100644 --- a/scenes/tracks/track.gd +++ b/scenes/tracks/track.gd @@ -5,12 +5,15 @@ signal time_updated(new_time) signal lap_complete(lap_time) signal wrong_way +const FINISH_GATE = preload("res://scenes/finish_gate.tscn") + export(NodePath) var track_path = null export(int, 10, 50) var checkpoint_count = 20 export(float) var checkpoint_depth = 5.0 export(PoolVector2Array) var checkpoint_polygon = PoolVector2Array( [Vector2(-10, -10), Vector2(-10, 10), Vector2(10, 10), Vector2(10, -10)] ) +export(Vector3) var gate_size = Vector3(20, 10, 5) var furthest_checkpoint = -1 var last_checkpoint = -1 @@ -44,6 +47,9 @@ func _ready() -> void: section += section_size checkpoints.add_child(new_checkpoint) new_checkpoint.connect("body_entered", self, "_on_body_entered_area", [new_checkpoint]) + var gate = FINISH_GATE.instance() + gate.scale = gate_size + checkpoints.get_child(0).add_child(gate) checkpoints.global_transform.origin = path.global_transform.origin diff --git a/scenes/tracks/track.tscn b/scenes/tracks/track.tscn index 88b7403..ec59601 100644 --- a/scenes/tracks/track.tscn +++ b/scenes/tracks/track.tscn @@ -1,15 +1,10 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=3 format=2] [ext_resource path="res://scenes/tracks/track.gd" type="Script" id=1] [ext_resource path="res://scenes/trackgui.tscn" type="PackedScene" id=2] -[sub_resource type="SpatialMaterial" id=7] -flags_transparent = true -albedo_color = Color( 0.0470588, 0.956863, 0.921569, 0.439216 ) - [node name="Track" type="Spatial"] script = ExtResource( 1 ) -debug_material = SubResource( 7 ) [node name="Checkpoints" type="Spatial" parent="."]