Add basic finish gate

pull/2/head
Ensar Sarajčić 2022-01-20 20:52:50 +01:00
parent 0c80cab346
commit bbde8b2ae7
5 changed files with 25 additions and 7 deletions

View File

@ -42,7 +42,7 @@ func reset_player_to(node_to_reset_to: Node, player_node: BuggedVehicle) -> void
).origin, ).origin,
node_to_reset_to.global_transform.basis.y 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(): func _spawn_in_player():

View File

@ -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

View File

@ -72,6 +72,7 @@ albedo_color = Color( 0.203922, 0.203922, 0.203922, 1 )
[node name="Track" parent="." index="1"] [node name="Track" parent="." index="1"]
track_path = NodePath("../Path") track_path = NodePath("../Path")
checkpoint_polygon = PoolVector2Array( -20, -4, -20, 10, 20, 10, 20, -4 ) 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"] [node name="Grass" type="StaticBody" parent="." index="2"]
transform = Transform( 0.8, 0, 0, 0, 1, 0, 0, 0, 0.4, 0, 5, 0 ) transform = Transform( 0.8, 0, 0, 0, 1, 0, 0, 0, 0.4, 0, 5, 0 )

View File

@ -5,12 +5,15 @@ signal time_updated(new_time)
signal lap_complete(lap_time) signal lap_complete(lap_time)
signal wrong_way signal wrong_way
const FINISH_GATE = preload("res://scenes/finish_gate.tscn")
export(NodePath) var track_path = null export(NodePath) var track_path = null
export(int, 10, 50) var checkpoint_count = 20 export(int, 10, 50) var checkpoint_count = 20
export(float) var checkpoint_depth = 5.0 export(float) var checkpoint_depth = 5.0
export(PoolVector2Array) var checkpoint_polygon = PoolVector2Array( export(PoolVector2Array) var checkpoint_polygon = PoolVector2Array(
[Vector2(-10, -10), Vector2(-10, 10), Vector2(10, 10), Vector2(10, -10)] [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 furthest_checkpoint = -1
var last_checkpoint = -1 var last_checkpoint = -1
@ -44,6 +47,9 @@ func _ready() -> void:
section += section_size section += section_size
checkpoints.add_child(new_checkpoint) checkpoints.add_child(new_checkpoint)
new_checkpoint.connect("body_entered", self, "_on_body_entered_area", [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 checkpoints.global_transform.origin = path.global_transform.origin

View File

@ -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/tracks/track.gd" type="Script" id=1]
[ext_resource path="res://scenes/trackgui.tscn" type="PackedScene" id=2] [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"] [node name="Track" type="Spatial"]
script = ExtResource( 1 ) script = ExtResource( 1 )
debug_material = SubResource( 7 )
[node name="Checkpoints" type="Spatial" parent="."] [node name="Checkpoints" type="Spatial" parent="."]