Start work on tile generator autoload

update tile positioning to work with the spawn points
This commit is contained in:
Matthew Welch 2024-10-05 14:09:45 -07:00
parent 932dfd8177
commit c1bb198be6
16 changed files with 372 additions and 169 deletions

View File

@ -2,16 +2,22 @@ extends Node3D
class_name Tile class_name Tile
@onready var follow = $MainPath/Follow as PathFollow3D
@onready var spawn_point = $SpawnPoint as Marker3D @onready var spawn_point = $SpawnPoint as Marker3D
@onready var progress_marker = $MainPath/Follow/ProgressMarker as Marker3D
var paths: Array[Path3D] var paths: Array[TilePath]
var path_index: int = 0 var path_index: int = 0
var path: Path3D: var path: TilePath:
get = get_current_path get = get_current_path
var follow: PathFollow3D:
get:
return path.follow
var progress_marker: Marker3D:
get:
return path.marker
var marker_position: Vector3: var marker_position: Vector3:
get: get:
return progress_marker.global_position return progress_marker.global_position
@ -27,12 +33,11 @@ func _ready():
func _process(delta): func _process(delta):
if is_equal_approx(follow.progress_ratio, 1) and has_next_path(): if is_equal_approx(follow.progress_ratio, 1) and has_next_path():
get_next_path().receive_marker(progress_marker)
path_index += 1 path_index += 1
follow = Utils.get_first_node_of_type(path, PathFollow3D) as PathFollow3D
progress_marker.reparent(follow)
func get_current_path() -> Path3D: func get_current_path() -> TilePath:
return paths[path_index] return paths[path_index]
@ -40,7 +45,7 @@ func has_next_path() -> bool:
return path_index + 1 < paths.size() return path_index + 1 < paths.size()
func get_next_path() -> Path3D: func get_next_path() -> TilePath:
if has_next_path(): if has_next_path():
return paths[path_index+1] return paths[path_index+1]
return null return null

View File

@ -1,6 +1,7 @@
[gd_scene load_steps=6 format=3 uid="uid://cvtgigpmwwv4g"] [gd_scene load_steps=7 format=3 uid="uid://cvtgigpmwwv4g"]
[ext_resource type="Script" path="res://Tiles/Tile.gd" id="1_wu32c"] [ext_resource type="Script" path="res://Tiles/tile.gd" id="1_wu32c"]
[ext_resource type="PackedScene" uid="uid://dh2nm1sphyfqx" path="res://Tiles/TilePath.tscn" id="2_ij0mq"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cwetn"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cwetn"]
cull_mode = 2 cull_mode = 2
@ -13,9 +14,9 @@ size = Vector2(10, 10)
material = SubResource("StandardMaterial3D_cwetn") material = SubResource("StandardMaterial3D_cwetn")
size = Vector2(2, 10) size = Vector2(2, 10)
[sub_resource type="Curve3D" id="Curve3D_q1k88"] [sub_resource type="Curve3D" id="Curve3D_q1142"]
_data = { _data = {
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, -5), "points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -10),
"tilts": PackedFloat32Array(0, 0) "tilts": PackedFloat32Array(0, 0)
} }
point_count = 2 point_count = 2
@ -24,26 +25,19 @@ point_count = 2
script = ExtResource("1_wu32c") script = ExtResource("1_wu32c")
[node name="Floor" type="MeshInstance3D" parent="."] [node name="Floor" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5)
mesh = SubResource("PlaneMesh_jju0s") mesh = SubResource("PlaneMesh_jju0s")
[node name="Wall1" type="MeshInstance3D" parent="."] [node name="Wall1" type="MeshInstance3D" parent="."]
transform = Transform3D(-4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0, 1, -5, 1, 0) transform = Transform3D(-4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0, 1, -5, 1, -5)
mesh = SubResource("PlaneMesh_rsriu") mesh = SubResource("PlaneMesh_rsriu")
[node name="Wall2" type="MeshInstance3D" parent="."] [node name="Wall2" type="MeshInstance3D" parent="."]
transform = Transform3D(-4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0, 1, 5, 1, 0) transform = Transform3D(-4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0, 1, 5, 1, -5)
mesh = SubResource("PlaneMesh_rsriu") mesh = SubResource("PlaneMesh_rsriu")
[node name="SpawnPoint" type="Marker3D" parent="."] [node name="SpawnPoint" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -10)
[node name="MainPath" type="Path3D" parent="."] [node name="MainPath" parent="." instance=ExtResource("2_ij0mq")]
curve = SubResource("Curve3D_q1k88") curve = SubResource("Curve3D_q1142")
[node name="Follow" type="PathFollow3D" parent="MainPath"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 5)
rotation_mode = 1
loop = false
tilt_enabled = false
[node name="ProgressMarker" type="Marker3D" parent="MainPath/Follow"]

12
Tiles/TilePath.tscn Normal file
View File

@ -0,0 +1,12 @@
[gd_scene load_steps=2 format=3 uid="uid://dh2nm1sphyfqx"]
[ext_resource type="Script" path="res://Tiles/tile_path.gd" id="1_6jxwt"]
[node name="TilePath" type="Path3D"]
script = ExtResource("1_6jxwt")
[node name="Follow" type="PathFollow3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 5)
rotation_mode = 1
loop = false
tilt_enabled = false

View File

@ -1,6 +1,7 @@
[gd_scene load_steps=6 format=3 uid="uid://fafw4evt372"] [gd_scene load_steps=7 format=3 uid="uid://fafw4evt372"]
[ext_resource type="Script" path="res://Tiles/Tile.gd" id="1_qgvt0"] [ext_resource type="Script" path="res://Tiles/tile.gd" id="1_qgvt0"]
[ext_resource type="PackedScene" uid="uid://dh2nm1sphyfqx" path="res://Tiles/TilePath.tscn" id="2_66bgp"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cwetn"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cwetn"]
cull_mode = 2 cull_mode = 2
@ -13,9 +14,9 @@ size = Vector2(10, 10)
material = SubResource("StandardMaterial3D_cwetn") material = SubResource("StandardMaterial3D_cwetn")
size = Vector2(2, 10) size = Vector2(2, 10)
[sub_resource type="Curve3D" id="Curve3D_q1k88"] [sub_resource type="Curve3D" id="Curve3D_8f65e"]
_data = { _data = {
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, -2.40419, 3.96713, 0, 0, 0, 0, 0, 0, 0, 2.60463, -4.68416), "points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0.00492096, 0.00431776, 0, 0, 0, 0, 0, 0, 0, 4.99628, -8.66443),
"tilts": PackedFloat32Array(0, 0) "tilts": PackedFloat32Array(0, 0)
} }
point_count = 2 point_count = 2
@ -24,27 +25,19 @@ point_count = 2
script = ExtResource("1_qgvt0") script = ExtResource("1_qgvt0")
[node name="Floor" type="MeshInstance3D" parent="."] [node name="Floor" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.866025, -0.5, 0, 0.5, 0.866025, 0, 0.0893164, -0.333333) transform = Transform3D(1, 0, 0, 0, 0.866025, -0.5, 0, 0.5, 0.866025, 0, 2.48097, -4.33106)
mesh = SubResource("PlaneMesh_jju0s") mesh = SubResource("PlaneMesh_jju0s")
[node name="Wall1" type="MeshInstance3D" parent="."] [node name="Wall1" type="MeshInstance3D" parent="."]
transform = Transform3D(-4.37114e-08, 1, 0, -0.866025, -3.78552e-08, -0.5, -0.5, -2.18557e-08, 0.866025, -5, 0.955342, 0.166667) transform = Transform3D(-4.37114e-08, 1, 0, -0.866025, -3.78552e-08, -0.5, -0.5, -2.18557e-08, 0.866025, -5, 3.347, -3.83106)
mesh = SubResource("PlaneMesh_rsriu") mesh = SubResource("PlaneMesh_rsriu")
[node name="Wall2" type="MeshInstance3D" parent="."] [node name="Wall2" type="MeshInstance3D" parent="."]
transform = Transform3D(-4.37114e-08, 1, 0, -0.866025, -3.78552e-08, -0.5, -0.5, -2.18557e-08, 0.866025, 5, 0.955342, 0.166667) transform = Transform3D(-4.37114e-08, 1, 0, -0.866025, -3.78552e-08, -0.5, -0.5, -2.18557e-08, 0.866025, 5, 3.347, -3.83106)
mesh = SubResource("PlaneMesh_rsriu") mesh = SubResource("PlaneMesh_rsriu")
[node name="SpawnPoint" type="Marker3D" parent="."] [node name="SpawnPoint" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.56806, -4.67077) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.95971, -8.6685)
[node name="MainPath" type="Path3D" parent="."] [node name="MainPath" parent="." instance=ExtResource("2_66bgp")]
curve = SubResource("Curve3D_q1k88") curve = SubResource("Curve3D_8f65e")
[node name="Follow" type="PathFollow3D" parent="MainPath"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.40419, 3.96713)
rotation_mode = 1
loop = false
tilt_enabled = false
[node name="ProgressMarker" type="Marker3D" parent="MainPath/Follow"]

View File

@ -1,110 +0,0 @@
[gd_scene load_steps=11 format=3 uid="uid://b88nuwe42bhc1"]
[ext_resource type="Script" path="res://Tiles/TileTurn.gd" id="1_wj6en"]
[ext_resource type="PackedScene" uid="uid://dkcjoccsgbggg" path="res://obstacles/obstacle.tscn" id="2_tnkvo"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cwetn"]
cull_mode = 2
[sub_resource type="PlaneMesh" id="PlaneMesh_jju0s"]
material = SubResource("StandardMaterial3D_cwetn")
size = Vector2(10, 10)
[sub_resource type="PlaneMesh" id="PlaneMesh_rsriu"]
material = SubResource("StandardMaterial3D_cwetn")
size = Vector2(2, 10)
[sub_resource type="Curve3D" id="Curve3D_q1k88"]
_data = {
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 1),
"tilts": PackedFloat32Array(0, 0)
}
point_count = 2
[sub_resource type="Curve3D" id="Curve3D_5ouye"]
_data = {
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -6),
"tilts": PackedFloat32Array(0, 0)
}
point_count = 2
[sub_resource type="Curve3D" id="Curve3D_dgywf"]
_data = {
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0),
"tilts": PackedFloat32Array(0, 0, 0)
}
point_count = 3
[sub_resource type="Curve3D" id="Curve3D_25twk"]
_data = {
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -5, 0, 0),
"tilts": PackedFloat32Array(0, 0, 0)
}
point_count = 3
[sub_resource type="BoxShape3D" id="BoxShape3D_uvh3q"]
size = Vector3(9.80943, 5.486, 17.6183)
[node name="Tile1" type="Node3D"]
script = ExtResource("1_wj6en")
[node name="Floor" type="MeshInstance3D" parent="."]
mesh = SubResource("PlaneMesh_jju0s")
[node name="Wall1" type="MeshInstance3D" parent="."]
transform = Transform3D(-4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0, 1, -5, 1, 0)
mesh = SubResource("PlaneMesh_rsriu")
[node name="Wall2" type="MeshInstance3D" parent="."]
transform = Transform3D(1.91069e-15, -4.37114e-08, 1, -1, -4.37114e-08, 0, 4.37114e-08, -1, -4.37114e-08, 0, 1, -5)
mesh = SubResource("PlaneMesh_rsriu")
[node name="SpawnPoint" type="Marker3D" parent="."]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 5, 0, 0)
[node name="MainPath" type="Path3D" parent="."]
curve = SubResource("Curve3D_q1k88")
[node name="Follow" type="PathFollow3D" parent="MainPath"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 5)
rotation_mode = 1
loop = false
tilt_enabled = false
[node name="ProgressMarker" type="Marker3D" parent="MainPath/Follow"]
[node name="PathForward" type="Path3D" parent="."]
curve = SubResource("Curve3D_5ouye")
[node name="Follow" type="PathFollow3D" parent="PathForward"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1)
rotation_mode = 1
loop = false
tilt_enabled = false
[node name="PathRight" type="Path3D" parent="."]
curve = SubResource("Curve3D_dgywf")
[node name="Follow" type="PathFollow3D" parent="PathRight"]
transform = Transform3D(0.999999, 0, 0, 0, 1, 0, 0, 0, 0.999999, 0, 0, 1)
rotation_mode = 1
loop = false
tilt_enabled = false
[node name="PathLeft" type="Path3D" parent="."]
curve = SubResource("Curve3D_25twk")
[node name="Follow" type="PathFollow3D" parent="PathLeft"]
transform = Transform3D(0.999999, 0, 0, 0, 1, 0, 0, 0, 0.999999, 0, 0, 1)
rotation_mode = 1
loop = false
tilt_enabled = false
[node name="Area3D" type="Area3D" parent="."]
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0194125, 2.2431, 4.34685)
shape = SubResource("BoxShape3D_uvh3q")
[node name="Obstacle" parent="." instance=ExtResource("2_tnkvo")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -5.14771)

86
Tiles/TileTurnLeft1.tscn Normal file
View File

@ -0,0 +1,86 @@
[gd_scene load_steps=12 format=3 uid="uid://c0xv7v6ako25a"]
[ext_resource type="Script" path="res://Tiles/tile_turn.gd" id="1_f1mql"]
[ext_resource type="PackedScene" uid="uid://dh2nm1sphyfqx" path="res://Tiles/TilePath.tscn" id="2_yvi2s"]
[ext_resource type="PackedScene" uid="uid://dkcjoccsgbggg" path="res://obstacles/Obstacle.tscn" id="3_us011"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cwetn"]
cull_mode = 2
[sub_resource type="PlaneMesh" id="PlaneMesh_jju0s"]
material = SubResource("StandardMaterial3D_cwetn")
size = Vector2(10, 10)
[sub_resource type="PlaneMesh" id="PlaneMesh_rsriu"]
material = SubResource("StandardMaterial3D_cwetn")
size = Vector2(2, 10)
[sub_resource type="Curve3D" id="Curve3D_r80si"]
_data = {
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -4),
"tilts": PackedFloat32Array(0, 0)
}
point_count = 2
[sub_resource type="Curve3D" id="Curve3D_gpbgb"]
_data = {
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0, -11),
"tilts": PackedFloat32Array(0, 0)
}
point_count = 2
[sub_resource type="Curve3D" id="Curve3D_f5rtl"]
_data = {
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0, -5, 0, 0, 0, 0, 0, 0, 5, 0, -5),
"tilts": PackedFloat32Array(0, 0, 0)
}
point_count = 3
[sub_resource type="Curve3D" id="Curve3D_a3s3y"]
_data = {
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0, -5, 0, 0, 0, 0, 0, 0, -5, 0, -5),
"tilts": PackedFloat32Array(0, 0, 0)
}
point_count = 3
[sub_resource type="BoxShape3D" id="BoxShape3D_uvh3q"]
size = Vector3(9.80943, 5.486, 17.6183)
[node name="Tile1" type="Node3D"]
script = ExtResource("1_f1mql")
[node name="Floor" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5)
mesh = SubResource("PlaneMesh_jju0s")
[node name="Wall1" type="MeshInstance3D" parent="."]
transform = Transform3D(4.37114e-08, -1, -8.74228e-08, -1, -4.37114e-08, 0, -3.82137e-15, 8.74228e-08, -1, 5, 1, -5)
mesh = SubResource("PlaneMesh_rsriu")
[node name="Wall2" type="MeshInstance3D" parent="."]
transform = Transform3D(1.91069e-15, -4.37114e-08, 1, -1, -4.37114e-08, 0, 4.37114e-08, -1, -4.37114e-08, 0, 1, -10)
mesh = SubResource("PlaneMesh_rsriu")
[node name="MainPath" parent="." instance=ExtResource("2_yvi2s")]
curve = SubResource("Curve3D_r80si")
[node name="PathForward" parent="." instance=ExtResource("2_yvi2s")]
curve = SubResource("Curve3D_gpbgb")
[node name="PathRight" parent="." instance=ExtResource("2_yvi2s")]
curve = SubResource("Curve3D_f5rtl")
[node name="PathLeft" parent="." instance=ExtResource("2_yvi2s")]
curve = SubResource("Curve3D_a3s3y")
[node name="SpawnPoint" type="Marker3D" parent="."]
transform = Transform3D(1.31134e-07, 0, 1, 0, 1, 0, -1, 0, 1.31134e-07, -5, 0, -5)
[node name="Area3D" type="Area3D" parent="."]
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0194125, 2.2431, -0.65315)
shape = SubResource("BoxShape3D_uvh3q")
[node name="Obstacle" parent="." instance=ExtResource("3_us011")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -10.1477)

86
Tiles/TileTurnRight1.tscn Normal file
View File

@ -0,0 +1,86 @@
[gd_scene load_steps=12 format=3 uid="uid://b88nuwe42bhc1"]
[ext_resource type="Script" path="res://Tiles/tile_turn.gd" id="1_wj6en"]
[ext_resource type="PackedScene" uid="uid://dkcjoccsgbggg" path="res://obstacles/Obstacle.tscn" id="2_tnkvo"]
[ext_resource type="PackedScene" uid="uid://dh2nm1sphyfqx" path="res://Tiles/TilePath.tscn" id="3_e2l5m"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cwetn"]
cull_mode = 2
[sub_resource type="PlaneMesh" id="PlaneMesh_jju0s"]
material = SubResource("StandardMaterial3D_cwetn")
size = Vector2(10, 10)
[sub_resource type="PlaneMesh" id="PlaneMesh_rsriu"]
material = SubResource("StandardMaterial3D_cwetn")
size = Vector2(2, 10)
[sub_resource type="Curve3D" id="Curve3D_r80si"]
_data = {
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -4),
"tilts": PackedFloat32Array(0, 0)
}
point_count = 2
[sub_resource type="Curve3D" id="Curve3D_gpbgb"]
_data = {
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0, -11),
"tilts": PackedFloat32Array(0, 0)
}
point_count = 2
[sub_resource type="Curve3D" id="Curve3D_f5rtl"]
_data = {
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0, -5, 0, 0, 0, 0, 0, 0, 5, 0, -5),
"tilts": PackedFloat32Array(0, 0, 0)
}
point_count = 3
[sub_resource type="Curve3D" id="Curve3D_jhtrd"]
_data = {
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, 0, -5, 0, 0, 0, 0, 0, 0, -5, 0, -5),
"tilts": PackedFloat32Array(0, 0, 0)
}
point_count = 3
[sub_resource type="BoxShape3D" id="BoxShape3D_uvh3q"]
size = Vector3(9.80943, 5.486, 17.6183)
[node name="Tile1" type="Node3D"]
script = ExtResource("1_wj6en")
[node name="Floor" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5)
mesh = SubResource("PlaneMesh_jju0s")
[node name="Wall1" type="MeshInstance3D" parent="."]
transform = Transform3D(-4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0, 1, -5, 1, -5)
mesh = SubResource("PlaneMesh_rsriu")
[node name="Wall2" type="MeshInstance3D" parent="."]
transform = Transform3D(1.91069e-15, -4.37114e-08, 1, -1, -4.37114e-08, 0, 4.37114e-08, -1, -4.37114e-08, 0, 1, -10)
mesh = SubResource("PlaneMesh_rsriu")
[node name="MainPath" parent="." instance=ExtResource("3_e2l5m")]
curve = SubResource("Curve3D_r80si")
[node name="PathForward" parent="." instance=ExtResource("3_e2l5m")]
curve = SubResource("Curve3D_gpbgb")
[node name="PathRight" parent="." instance=ExtResource("3_e2l5m")]
curve = SubResource("Curve3D_f5rtl")
[node name="PathLeft" parent="." instance=ExtResource("3_e2l5m")]
curve = SubResource("Curve3D_jhtrd")
[node name="SpawnPoint" type="Marker3D" parent="."]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 5, 0, 0)
[node name="Area3D" type="Area3D" parent="."]
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0194125, 2.2431, -0.65315)
shape = SubResource("BoxShape3D_uvh3q")
[node name="Obstacle" parent="." instance=ExtResource("2_tnkvo")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -10.1477)

26
Tiles/tile_path.gd Normal file
View File

@ -0,0 +1,26 @@
extends Path3D
class_name TilePath
@onready var follow = $Follow as PathFollow3D
var _marker: Marker3D
var marker: Marker3D:
get:
if not has_progress_marker():
create_marker()
return _marker
func has_progress_marker() -> bool:
return _marker != null
func create_marker() -> Marker3D:
_marker = Marker3D.new()
follow.add_child(_marker)
return _marker
func receive_marker(node: Marker3D) -> void:
node.reparent(follow)
_marker = node

View File

@ -2,13 +2,17 @@ extends Tile
class_name TileTurn class_name TileTurn
@onready var area_3d = $Area3D as Area3D @onready var area_3d = $Area3D as Area3D
@onready var path_forward = $PathForward as Path3D @onready var path_forward = $PathForward as TilePath
@onready var path_right = $PathRight as Path3D @onready var path_right = $PathRight as TilePath
@onready var path_left = $PathLeft as Path3D @onready var path_left = $PathLeft as TilePath
var connected = false var connected = false
var current_direction = "forward" var current_direction = "forward"
var on_main_path = true var character: Character
var on_main_path: bool:
get:
return path_index == 0
func _ready(): func _ready():
@ -17,11 +21,18 @@ func _ready():
func _process(delta): func _process(delta):
var character_found = false
for area in area_3d.get_overlapping_areas(): for area in area_3d.get_overlapping_areas():
if area is Character and not connected: if area is Character:
var character = area as Character character_found = true
if connected:
break
character = area as Character
character.turn.connect(turn) character.turn.connect(turn)
connected = true connected = true
if not character_found and connected:
character.turn.disconnect(turn)
connected = false
super(delta) super(delta)
@ -31,7 +42,7 @@ func turn(direction):
paths[path_index+1] = get_path_by_direction(current_direction) paths[path_index+1] = get_path_by_direction(current_direction)
func get_path_by_direction(direction) -> Path3D: func get_path_by_direction(direction) -> TilePath:
if direction == "forward" and path_forward != null: if direction == "forward" and path_forward != null:
return path_forward return path_forward
elif direction == "right" and path_right != null: elif direction == "right" and path_right != null:

View File

@ -1,12 +1,12 @@
[gd_scene load_steps=3 format=3 uid="uid://dkcjoccsgbggg"] [gd_scene load_steps=3 format=3 uid="uid://dkcjoccsgbggg"]
[ext_resource type="Script" path="res://obstacles/obstacle.gd" id="1_ab8so"] [ext_resource type="Script" path="res://obstacles/obstacle.gd" id="1_78mjh"]
[sub_resource type="BoxShape3D" id="BoxShape3D_c6wik"] [sub_resource type="BoxShape3D" id="BoxShape3D_c6wik"]
size = Vector3(10, 2, 0.5) size = Vector3(10, 2, 0.5)
[node name="Obstacle" type="Area3D"] [node name="Obstacle" type="Area3D"]
script = ExtResource("1_ab8so") script = ExtResource("1_78mjh")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] [node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("BoxShape3D_c6wik") shape = SubResource("BoxShape3D_c6wik")

View File

@ -18,6 +18,7 @@ config/icon="res://icon.svg"
[autoload] [autoload]
Utils="*res://utils.gd" Utils="*res://utils.gd"
TileGenerator="*res://tile_generator.gd"
[rendering] [rendering]

54
tile_generator.gd Normal file
View File

@ -0,0 +1,54 @@
extends Node
var tile_set = preload("res://tile_set1.tres") as FR_TileSet
var tiles: Array[Tile]
var run_started = false
var tile_parent: Node
func _ready():
pass
func _process(delta):
if not run_started:
return
if tiles.size() == 0:
return
if tiles.size() < 15:
add_tile()
#if is_equal_approx(current_tile.follow.progress_ratio, 1) and has_next_tile():
#if current_tile.has_next_path():
#return
#tile_index += 1
#character.tile = current_tile
func start_run(tile_parent: Node) -> void:
self.tile_parent = tile_parent
get_current_tiles()
if tiles.size() == 0:
var tile = generate_tile()
tiles.append(tile)
tile_parent.add_child(tile)
run_started = true
func get_current_tiles() -> void:
tiles.assign(Utils.get_nodes_of_class(get_tree().root, Tile))
func generate_tile() -> Tile:
var index = randi_range(0, tile_set.strait_tiles.size()-1)
var tile_scene: PackedScene = tile_set.strait_tiles[index]
var tile = tile_scene.instantiate()
return tile
func add_tile() -> void:
var last_tile = tiles[tiles.size()-1]
var tile = generate_tile()
tiles.append(tile)
tile_parent.add_child(tile)
tile.global_position = last_tile.spawn_point.global_position
tile.global_rotation = last_tile.spawn_point.global_rotation

6
tile_set.gd Normal file
View File

@ -0,0 +1,6 @@
extends Resource
class_name FR_TileSet
@export var strait_tiles: Array[PackedScene]
@export var ramp_tiles: Array[PackedScene]
@export var turn_tiles: Array[PackedScene]

12
tile_set1.tres Normal file
View File

@ -0,0 +1,12 @@
[gd_resource type="Resource" script_class="FR_TileSet" load_steps=5 format=3 uid="uid://b1bl33xgipadd"]
[ext_resource type="Script" path="res://tile_set.gd" id="1_oesq8"]
[ext_resource type="PackedScene" uid="uid://cvtgigpmwwv4g" path="res://Tiles/Tile1.tscn" id="3_4xf43"]
[ext_resource type="PackedScene" uid="uid://c0xv7v6ako25a" path="res://Tiles/TileTurnLeft1.tscn" id="4_xn546"]
[ext_resource type="PackedScene" uid="uid://b88nuwe42bhc1" path="res://Tiles/TileTurnRight1.tscn" id="5_tir2o"]
[resource]
script = ExtResource("1_oesq8")
strait_tiles = Array[PackedScene]([ExtResource("3_4xf43")])
ramp_tiles = Array[PackedScene]([null])
turn_tiles = Array[PackedScene]([ExtResource("4_xn546"), ExtResource("5_tir2o")])

View File

@ -17,6 +17,7 @@ func _ready() -> void:
return return
if character.tile == null: if character.tile == null:
character.tile = current_tile character.tile = current_tile
TileGenerator.start_run(self)
func _process(delta: float) -> void: func _process(delta: float) -> void:

View File

@ -1,14 +1,31 @@
[gd_scene load_steps=6 format=3 uid="uid://blupjt2ulo2g1"] [gd_scene load_steps=10 format=3 uid="uid://blupjt2ulo2g1"]
[ext_resource type="PackedScene" uid="uid://vamte52rvfhy" path="res://character/character.tscn" id="1_nfwx6"] [ext_resource type="PackedScene" uid="uid://vamte52rvfhy" path="res://character/Character.tscn" id="1_nfwx6"]
[ext_resource type="Script" path="res://world.gd" id="1_oloil"] [ext_resource type="Script" path="res://world.gd" id="1_oloil"]
[ext_resource type="PackedScene" uid="uid://cvtgigpmwwv4g" path="res://Tiles/Tile1.tscn" id="3_vddfn"] [ext_resource type="PackedScene" uid="uid://cvtgigpmwwv4g" path="res://Tiles/Tile1.tscn" id="3_vddfn"]
[ext_resource type="PackedScene" uid="uid://fafw4evt372" path="res://Tiles/TileRamp1.tscn" id="4_uxk3v"] [ext_resource type="PackedScene" uid="uid://fafw4evt372" path="res://Tiles/TileRamp1.tscn" id="4_uxk3v"]
[ext_resource type="PackedScene" uid="uid://b88nuwe42bhc1" path="res://Tiles/TileTurn1.tscn" id="5_ynp1e"] [ext_resource type="PackedScene" uid="uid://b88nuwe42bhc1" path="res://Tiles/TileTurnRight1.tscn" id="5_ynp1e"]
[ext_resource type="PackedScene" uid="uid://c0xv7v6ako25a" path="res://Tiles/TileTurnLeft1.tscn" id="6_327qh"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_dhu5e"]
sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
ground_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
[sub_resource type="Sky" id="Sky_16rbt"]
sky_material = SubResource("ProceduralSkyMaterial_dhu5e")
[sub_resource type="Environment" id="Environment_c08wk"]
background_mode = 2
sky = SubResource("Sky_16rbt")
tonemap_mode = 2
glow_enabled = true
[node name="World" type="Node3D"] [node name="World" type="Node3D"]
script = ExtResource("1_oloil") script = ExtResource("1_oloil")
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_c08wk")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] [node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(0.763207, -0.546639, 0.344531, 0.296667, 0.770123, 0.564712, -0.574024, -0.328781, 0.749933, 3.45982, 2.03445, -6.78341) transform = Transform3D(0.763207, -0.546639, 0.344531, 0.296667, 0.770123, 0.564712, -0.574024, -0.328781, 0.749933, 3.45982, 2.03445, -6.78341)
shadow_enabled = true shadow_enabled = true
@ -22,13 +39,22 @@ tile = NodePath("../Tile1")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -10) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -10)
[node name="Tile3" parent="." instance=ExtResource("4_uxk3v")] [node name="Tile3" parent="." instance=ExtResource("4_uxk3v")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.49484, -19.3201) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0861304, -19.3201)
[node name="Tile4" parent="." instance=ExtResource("3_vddfn")] [node name="Tile4" parent="." instance=ExtResource("3_vddfn")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, -28.6473) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, -27.9971)
[node name="Tile5" parent="." instance=ExtResource("5_ynp1e")] [node name="Tile5" parent="." instance=ExtResource("5_ynp1e")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, -38.641) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, -37.9673)
[node name="Tile6" parent="." instance=ExtResource("3_vddfn")] [node name="Tile6" parent="." instance=ExtResource("3_vddfn")]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 10, 5, -38.6473) transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 5.01222, 5, -42.9558)
[node name="Tile7" parent="." instance=ExtResource("5_ynp1e")]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 15.0122, 5, -42.9555)
[node name="Tile8" parent="." instance=ExtResource("3_vddfn")]
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 20, 5, -37.9705)
[node name="Tile9" parent="." instance=ExtResource("6_327qh")]
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 20, 5, -27.9764)