This commit is contained in:
Overside srl
2026-02-01 09:53:24 +01:00
parent 8222c7613d
commit 40cadd2f73
21 changed files with 300 additions and 98 deletions

View File

@@ -1,14 +1,14 @@
Button
Area3D
Node3D
Path3D Path3D
RemoteTransform3D CSGPolygon3D
PathFollow3D PathFollow3D
RemoteTransform3D
MeshInstance3D MeshInstance3D
CollisionShape3D CollisionShape3D
RigidBody3D RigidBody3D
CSGPolygon3D
Label Label
TextureRect TextureRect
Panel Panel
VBoxContainer VBoxContainer
Button
Control
Node3D

View File

@@ -22,7 +22,7 @@ dock_hsplit_1=0
dock_hsplit_2=270 dock_hsplit_2=270
dock_hsplit_3=-270 dock_hsplit_3=-270
dock_hsplit_4=0 dock_hsplit_4=0
dock_9_selected_tab_idx=0 dock_9_selected_tab_idx=1
dock_3="Scene,Import" dock_3="Scene,Import"
dock_4="FileSystem" dock_4="FileSystem"
dock_5="Inspector,History,Signals,Groups" dock_5="Inspector,History,Signals,Groups"
@@ -30,10 +30,10 @@ dock_9="Output,Debugger,Audio,Animation,Shader Editor,Search Results,AnimationTr
[EditorNode] [EditorNode]
open_scenes=PackedStringArray("res://scenes/main.tscn", "res://scenes/gamestate.tscn") open_scenes=PackedStringArray("res://scenes/train_control.tscn")
current_scene="res://scenes/main.tscn" current_scene="res://scenes/train_control.tscn"
center_split_offset=-864 center_split_offset=-864
selected_default_debugger_tab_idx=1 selected_default_debugger_tab_idx=0
selected_main_editor_idx=2 selected_main_editor_idx=2
selected_bottom_panel_item=0 selected_bottom_panel_item=0
bottom_panel_offsets={ bottom_panel_offsets={
@@ -53,8 +53,8 @@ size=Vector2i(4294, 3405)
[ScriptEditor] [ScriptEditor]
open_scripts=["res://scripts/engine.gd", "res://scripts/gamestate.gd", "res://scripts/main.gd", "res://scripts/objloader.gd", "res://scripts/scene_switcher.gd", "res://scripts/track_generator.gd", "res://scripts/train.gd", "res://scripts/traincontrol.gd", "res://scripts/traincontrol_camera.gd", "res://scripts/trainjourney.gd", "res://scripts/trainjourney_camera.gd", "res://scripts/train_movement.gd"] open_scripts=["res://scripts/engine.gd", "res://scripts/gamestate.gd", "res://scripts/main.gd", "res://scripts/objloader.gd", "res://scripts/rail_swtich.gd", "res://scripts/scene_switcher.gd", "res://scripts/track_generator.gd", "res://scripts/train.gd", "res://scripts/traincontrol.gd", "res://scripts/traincontrol_camera.gd", "res://scripts/trainjourney.gd", "res://scripts/trainjourney_camera.gd", "res://scripts/train_movement.gd"]
selected_script="res://scripts/main.gd" selected_script="res://scripts/train_movement.gd"
open_help=[] open_help=[]
script_split_offset=400 script_split_offset=400
list_split_offset=0 list_split_offset=0
@@ -79,10 +79,20 @@ v_split_offset=0
display_mode=0 display_mode=0
file_sort=0 file_sort=0
file_list_display_mode=1 file_list_display_mode=1
selected_paths=PackedStringArray("res://scripts/main.gd") selected_paths=PackedStringArray("res://scenes/train_control.tscn")
uncollapsed_paths=PackedStringArray("res://", "res://scripts/", "res://resources/train kit/") uncollapsed_paths=PackedStringArray("res://", "res://scripts/", "res://scenes/", "res://resources/train kit/")
[docks/History] [docks/History]
include_scene=true include_scene=true
include_global=true include_global=true
[editor_log]
log_filter_0=true
log_filter_2=true
log_filter_1=true
log_filter_3=true
log_filter_4=true
collapse=false
show_search=true

Binary file not shown.

View File

@@ -1,5 +1,5 @@
63f7b34db8d8cdea90c76aacccf841ec 63f7b34db8d8cdea90c76aacccf841ec
::res://::1769537417 ::res://::1769935928
export_presets.cfg::TextFile::-1::1768659892::0::1::::<><><>0<>0<><>:: export_presets.cfg::TextFile::-1::1768659892::0::1::::<><><>0<>0<><>::
::res://build/::1769525949 ::res://build/::1769525949
::res://resources/::1769500126 ::res://resources/::1769500126
@@ -114,23 +114,25 @@ train-tram-modern.obj::Mesh::7951114505230208222::1727040295::1768551393::1::::<
train-tram-round.obj::Mesh::115250456338501034::1727040295::1768551393::1::::<><><>0<>0<>5e3772ddb59635a364b94e1db000bd4a<>res://.godot/imported/train-tram-round.obj-1b613e087f922f3f788c8bf27b8a5616.mesh<*>res://.godot/imported/train-tram-round.obj-1b613e087f922f3f788c8bf27b8a5616.mesh::uid://cdwwcby54pecs::::res://resources/train kit/Textures/colormap.png train-tram-round.obj::Mesh::115250456338501034::1727040295::1768551393::1::::<><><>0<>0<>5e3772ddb59635a364b94e1db000bd4a<>res://.godot/imported/train-tram-round.obj-1b613e087f922f3f788c8bf27b8a5616.mesh<*>res://.godot/imported/train-tram-round.obj-1b613e087f922f3f788c8bf27b8a5616.mesh::uid://cdwwcby54pecs::::res://resources/train kit/Textures/colormap.png
::res://resources/train kit/Textures/::1769067197 ::res://resources/train kit/Textures/::1769067197
colormap.png::CompressedTexture2D::5030163645319353198::1727040840::1768551396::1::::<><><>0<>0<>49486029a612050ab47ae771aec92b8c<>res://.godot/imported/colormap.png-d3d02b00fd834f010bf45b2b9259ea63.s3tc.ctex:: colormap.png::CompressedTexture2D::5030163645319353198::1727040840::1768551396::1::::<><><>0<>0<>49486029a612050ab47ae771aec92b8c<>res://.godot/imported/colormap.png-d3d02b00fd834f010bf45b2b9259ea63.s3tc.ctex::
::res://scenes/::1769537407 ::res://scenes/::1769878170
gamestate.tscn::PackedScene::4137542781585662412::1769537142::0::1::::<><><>0<>0<><>::uid://s80bt8i6u2hv::::res://scripts/gamestate.gd gamestate.tscn::PackedScene::4137542781585662412::1769537142::0::1::::<><><>0<>0<><>::uid://s80bt8i6u2hv::::res://scripts/gamestate.gd
main.tscn::PackedScene::6062849282872582400::1769537407::0::1::::<><><>0<>0<><>::uid://cfjaa6hq1wpvd::::res://scripts/main.gd main.tscn::PackedScene::6062849282872582400::1769537468::0::1::::<><><>0<>0<><>::uid://cfjaa6hq1wpvd::::res://scripts/main.gd
musicmanager.tscn::PackedScene::1158465914396145662::1769536753::0::1::::<><><>0<>0<><>::uid://bdluyy5uodjb5::::res://resources/thomastanks_new.mp3 musicmanager.tscn::PackedScene::1158465914396145662::1769536753::0::1::::<><><>0<>0<><>::uid://bdluyy5uodjb5::::res://resources/thomastanks_new.mp3
train.tscn::PackedScene::5090417957456705533::1769536752::0::1::::<><><>0<>0<><>:: train.tscn::PackedScene::5090417957456705533::1769536752::0::1::::<><><>0<>0<><>::
trainjourney.tscn::PackedScene::7111673961189096216::1769536751::0::1::::<><><>0<>0<><>::uid://dfyo0h5yj3us8::::res://scripts/trainjourney.gd<>uid://csm5ihvpyw5m7::::res://scenes/main.tscn<>uid://bymoo78gun6a4::::res://scripts/track_generator.gd<>uid://cer3o7xlhju7v::::res://scenes/train.tscn<>uid://cvn333pymsowx::::res://scripts/train.gd<>uid://cgy51h6a5syer::::res://scripts/trainjourney_camera.gd<>uid://bi2atrvjj23tk::::res://resources/audio_on.png<>uid://qrf08uiuhyqg::::res://scenes/musicmanager.tscn<>uid://n6bjl02ikh00::::res://resources/audio_off.png<>uid://by7iywhy2d8uy::::res://scenes/gamestate.tscn trainjourney.tscn::PackedScene::7111673961189096216::1769536751::0::1::::<><><>0<>0<><>::uid://dfyo0h5yj3us8::::res://scripts/trainjourney.gd<>uid://csm5ihvpyw5m7::::res://scenes/main.tscn<>uid://bymoo78gun6a4::::res://scripts/track_generator.gd<>uid://cer3o7xlhju7v::::res://scenes/train.tscn<>uid://cvn333pymsowx::::res://scripts/train.gd<>uid://cgy51h6a5syer::::res://scripts/trainjourney_camera.gd<>uid://bi2atrvjj23tk::::res://resources/audio_on.png<>uid://qrf08uiuhyqg::::res://scenes/musicmanager.tscn<>uid://n6bjl02ikh00::::res://resources/audio_off.png<>uid://by7iywhy2d8uy::::res://scenes/gamestate.tscn
train_control.tscn::PackedScene::7634187837543058913::1769536757::0::1::::<><><>0<>0<><>::uid://ckndmko4orxx::::res://scripts/traincontrol.gd<>uid://bg24v3kb5e73l::::res://resources/rail2.png<>uid://csm5ihvpyw5m7::::res://scenes/main.tscn<>uid://ck4j0pekoofm1::::res://scripts/engine.gd<>uid://cm8un80nubjbi::::res://resources/train kit/train-diesel-a.obj<>uid://b65vwus8xxmun::::res://scripts/traincontrol_camera.gd<>uid://df2oi5vyeak81::::res://scripts/train_movement.gd train_control.tscn::PackedScene::7634187837543058913::1769878170::0::1::::<><><>0<>0<><>::uid://ckndmko4orxx::::res://scripts/traincontrol.gd<>uid://bg24v3kb5e73l::::res://resources/rail2.png<>uid://csm5ihvpyw5m7::::res://scenes/main.tscn<>uid://ck4j0pekoofm1::::res://scripts/engine.gd<>uid://cm8un80nubjbi::::res://resources/train kit/train-diesel-a.obj<>uid://b65vwus8xxmun::::res://scripts/traincontrol_camera.gd<>uid://df2oi5vyeak81::::res://scripts/train_movement.gd<>uid://b5x80gpkn1swt::::res://scripts/rail_swtich.gd
::res://scripts/::1769537142 ::res://scripts/::1769878171
engine.gd::GDScript::5535188650919869270::1769520398::0::1::::TrainEngine<>PathFollow3D<><>0<>0<><>:: engine.gd::GDScript::5535188650919869270::1769877447::0::1::::<>PathFollow3D<><>0<>0<><>::
gamestate.gd::GDScript::1333044411309547839::1769079115::0::1::::<>Node<><>0<>0<><>:: gamestate.gd::GDScript::1333044411309547839::1769079115::0::1::::<>Node<><>0<>0<><>::
main.gd::GDScript::5142366625162981657::1769537142::0::1::::<>Control<><>0<>0<><>:: main.gd::GDScript::5142366625162981657::1769537142::0::1::::<>Control<><>0<>0<><>::
objloader.gd::GDScript::2596173299165953535::1768586602::0::1::::OBJLoader<>RefCounted<><>0<>0<><>:: objloader.gd::GDScript::2596173299165953535::1768586602::0::1::::OBJLoader<>RefCounted<><>0<>0<><>::
rail_switch.gd::GDScript::84664361793048242::1769876403::0::1::::RailSwitch<>Area3D<><>0<>0<><>::
rail_swtich.gd::GDScript::4541615325571300327::1769877343::0::1::::<>Area3D<><>0<>0<><>::
scene_switcher.gd::GDScript::9078813208397392183::1769536784::0::1::::<>Node<><>0<>0<><>:: scene_switcher.gd::GDScript::9078813208397392183::1769536784::0::1::::<>Node<><>0<>0<><>::
track_generator.gd::GDScript::4096602235093631041::1768587411::0::1::::TrackGenerator<>Node3D<><>0<>0<><>:: track_generator.gd::GDScript::4096602235093631041::1768587411::0::1::::TrackGenerator<>Node3D<><>0<>0<><>::
train.gd::GDScript::6275395567547538251::1769079965::0::1::::Train<>Node3D<><>0<>0<><>:: train.gd::GDScript::6275395567547538251::1769079965::0::1::::Train<>Node3D<><>0<>0<><>::
traincontrol.gd::GDScript::161816789508007529::1769520732::0::1::::<>Node3D<><>0<>0<><>:: traincontrol.gd::GDScript::161816789508007529::1769878171::0::1::::<>Node3D<><>0<>0<><>::
traincontrol_camera.gd::GDScript::4625521593212407341::1769519796::0::1::::TrainControlCamera<>Camera3D<><>0<>0<><>:: traincontrol_camera.gd::GDScript::4625521593212407341::1769519796::0::1::::TrainControlCamera<>Camera3D<><>0<>0<><>::
trainjourney.gd::GDScript::7560646433224437573::1769519382::0::1::::<>Node3D<><>0<>0<><>:: trainjourney.gd::GDScript::7560646433224437573::1769519382::0::1::::<>Node3D<><>0<>0<><>::
trainjourney_camera.gd::GDScript::5245387851329565609::1769519365::0::1::::TrainJourneyCamera<>Camera3D<><>0<>0<><>:: trainjourney_camera.gd::GDScript::5245387851329565609::1769519365::0::1::::TrainJourneyCamera<>Camera3D<><>0<>0<><>::
train_movement.gd::GDScript::7566810402116253988::1769521010::0::1::::<>MeshInstance3D<><>0<>0<><>:: train_movement.gd::GDScript::7566810402116253988::1769878156::0::1::::TrainBody<>MeshInstance3D<><>0<>0<><>::

View File

@@ -1 +0,0 @@
res://scenes/main.tscn

View File

@@ -10,8 +10,8 @@ use_advanced_connections=false
[recent_files] [recent_files]
scenes=["res://scenes/gamestate.tscn", "res://scenes/main.tscn", "res://scenes/train_control.tscn", "res://scenes/musicmanager.tscn", "res://scenes/train.tscn", "res://scenes/trainjourney.tscn", "res://scenes/game_state.tscn", "res://scenes/wagon.tscn"] scenes=["res://scenes/train_control.tscn", "res://scenes/main.tscn", "res://scenes/gamestate.tscn", "res://scenes/musicmanager.tscn", "res://scenes/train.tscn", "res://scenes/trainjourney.tscn", "res://scenes/game_state.tscn", "res://scenes/wagon.tscn"]
scripts=["res://scripts/main.gd", "res://scripts/scene_switcher.gd", "res://scripts/objloader.gd", "res://scripts/traincontrol.gd", "res://scripts/traincontrol_camera.gd", "res://scripts/train_movement.gd", "res://scripts/engine.gd", "res://scripts/trainjourney_camera.gd", "res://scripts/train.gd", "res://scripts/track_generator.gd"] scripts=["res://scripts/rail_swtich.gd", "res://scripts/rail_switch.gd", "res://scripts/main.gd", "res://scripts/scene_switcher.gd", "res://scripts/objloader.gd", "res://scripts/traincontrol.gd", "res://scripts/traincontrol_camera.gd", "res://scripts/train_movement.gd", "res://scripts/engine.gd", "res://scripts/trainjourney_camera.gd"]
[dialog_bounds] [dialog_bounds]

View File

@@ -0,0 +1,3 @@
[folding]
sections_unfolded=PackedStringArray()

View File

@@ -0,0 +1,3 @@
[folding]
sections_unfolded=PackedStringArray()

View File

@@ -21,7 +21,7 @@ state={
"folded_lines": PackedInt32Array(), "folded_lines": PackedInt32Array(),
"h_scroll_position": 0, "h_scroll_position": 0,
"row": 131, "row": 131,
"scroll_position": 102.0, "scroll_position": 0.0,
"selection": true, "selection": true,
"selection_from_column": 1, "selection_from_column": 1,
"selection_from_line": 131, "selection_from_line": 131,
@@ -67,7 +67,7 @@ state={
"folded_lines": PackedInt32Array(), "folded_lines": PackedInt32Array(),
"h_scroll_position": 0, "h_scroll_position": 0,
"row": 33, "row": 33,
"scroll_position": 4.0, "scroll_position": 15.0,
"selection": false, "selection": false,
"syntax_highlighter": "GDScript" "syntax_highlighter": "GDScript"
} }
@@ -105,10 +105,10 @@ state={
state={ state={
"bookmarks": PackedInt32Array(), "bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(), "breakpoints": PackedInt32Array(),
"column": 29, "column": 50,
"folded_lines": PackedInt32Array(), "folded_lines": PackedInt32Array(),
"h_scroll_position": 0, "h_scroll_position": 0,
"row": 9, "row": 5,
"scroll_position": 0.0, "scroll_position": 0.0,
"selection": false, "selection": false,
"syntax_highlighter": "GDScript" "syntax_highlighter": "GDScript"
@@ -123,7 +123,7 @@ state={
"folded_lines": PackedInt32Array(), "folded_lines": PackedInt32Array(),
"h_scroll_position": 0, "h_scroll_position": 0,
"row": 52, "row": 52,
"scroll_position": 23.0, "scroll_position": 30.0,
"selection": false, "selection": false,
"syntax_highlighter": "GDScript" "syntax_highlighter": "GDScript"
} }
@@ -132,12 +132,12 @@ state={
state={ state={
"bookmarks": PackedInt32Array(), "bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(), "breakpoints": PackedInt32Array(25),
"column": 0, "column": 22,
"folded_lines": PackedInt32Array(), "folded_lines": PackedInt32Array(),
"h_scroll_position": 0, "h_scroll_position": 0,
"row": 15, "row": 18,
"scroll_position": 0.0, "scroll_position": 16.0,
"selection": false, "selection": false,
"syntax_highlighter": "GDScript" "syntax_highlighter": "GDScript"
} }
@@ -175,10 +175,38 @@ state={
state={ state={
"bookmarks": PackedInt32Array(), "bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(), "breakpoints": PackedInt32Array(),
"column": 1, "column": 0,
"folded_lines": PackedInt32Array(), "folded_lines": PackedInt32Array(),
"h_scroll_position": 0, "h_scroll_position": 0,
"row": 7, "row": 11,
"scroll_position": 11.0,
"selection": false,
"syntax_highlighter": "GDScript"
}
[res://scripts/rail_switch.gd]
state={
"bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(),
"column": 0,
"folded_lines": PackedInt32Array(),
"h_scroll_position": 0,
"row": 0,
"scroll_position": 0.0,
"selection": false,
"syntax_highlighter": "GDScript"
}
[res://scripts/rail_swtich.gd]
state={
"bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(),
"column": 18,
"folded_lines": PackedInt32Array(),
"h_scroll_position": 0,
"row": 8,
"scroll_position": 0.0, "scroll_position": 0.0,
"selection": false, "selection": false,
"syntax_highlighter": "GDScript" "syntax_highlighter": "GDScript"

View File

@@ -5,7 +5,7 @@
"grid_snap_active": false, "grid_snap_active": false,
"grid_step": Vector2(8, 8), "grid_step": Vector2(8, 8),
"grid_visibility": 1, "grid_visibility": 1,
"ofs": Vector2(-927.8054, -93.71013), "ofs": Vector2(-247.07657, 26.025288),
"primary_grid_step": Vector2i(8, 8), "primary_grid_step": Vector2i(8, 8),
"show_group_gizmos": true, "show_group_gizmos": true,
"show_guides": true, "show_guides": true,
@@ -31,7 +31,7 @@
"snap_rotation_step": 0.2617994, "snap_rotation_step": 0.2617994,
"snap_scale": false, "snap_scale": false,
"snap_scale_step": 0.1, "snap_scale_step": 0.1,
"zoom": 1.1 "zoom": 1.6105102
} }
3D={ 3D={
"fov": 70.01, "fov": 70.01,
@@ -103,7 +103,7 @@
"auto_orthogonal_enabled": true, "auto_orthogonal_enabled": true,
"cinematic_preview": false, "cinematic_preview": false,
"display_mode": 22, "display_mode": 22,
"distance": 73.97322, "distance": 11.794629,
"doppler": false, "doppler": false,
"frame_time": false, "frame_time": false,
"gizmos": true, "gizmos": true,
@@ -113,12 +113,12 @@
"listener": true, "listener": true,
"lock_rotation": false, "lock_rotation": false,
"orthogonal": false, "orthogonal": false,
"position": Vector3(0, 0, 0), "position": Vector3(18.173706, 3.0913553, 48.05532),
"transform_gizmo": true, "transform_gizmo": true,
"use_environment": false, "use_environment": false,
"view_type": 0, "view_type": 0,
"x_rotation": 1.4740068, "x_rotation": 0.34826988,
"y_rotation": 1.8626451e-08 "y_rotation": -0.97738516
}, { }, {
"auto_orthogonal": false, "auto_orthogonal": false,
"auto_orthogonal_enabled": true, "auto_orthogonal_enabled": true,
@@ -189,4 +189,4 @@
Anim={ Anim={
"visible": false "visible": false
} }
selected_nodes=Array[NodePath]([]) selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@18065/@Panel@14/@VBoxContainer@15/DockHSplitMain/@VBoxContainer@28/DockVSplitCenter/@VSplitContainer@70/@VBoxContainer@71/@EditorMainScreen@125/MainScreen/@CanvasItemEditor@9318/@VSplitContainer@9101/@HSplitContainer@9103/@HSplitContainer@9105/@Control@9106/@SubViewportContainer@9107/@SubViewport@9108/TrainControl/Ground/Train")])

View File

@@ -1,5 +1,5 @@
[folding] [folding]
node_unfolds=[NodePath("Ground"), PackedStringArray("Transform", "surface_material_override", "surface_material_override/0", "mesh"), NodePath("Ground/Rails"), PackedStringArray("Transform", "Debug Shape", "curve"), NodePath("Ground/Rails/Ballast"), PackedStringArray("Transform", "Geometry"), NodePath("Ground/Rails/LRail"), PackedStringArray("polygon", "Transform"), NodePath("Ground/Rails/RRail"), PackedStringArray("Transform", "polygon"), NodePath("Ground/Rails/TrainEngine"), PackedStringArray("Transform"), NodePath("Ground/Rails/TrainEngine/Train"), PackedStringArray("Skeleton", "Geometry", "Transform"), NodePath("DirectionalLight3D"), PackedStringArray("Light", "Shadow"), NodePath("WorldEnvironment"), PackedStringArray("environment"), NodePath("TrainCamera"), PackedStringArray("Transform")] node_unfolds=[NodePath("Ground"), PackedStringArray("Transform", "surface_material_override", "surface_material_override/0", "mesh"), NodePath("Ground/Train"), PackedStringArray("Skeleton", "Geometry", "Transform", "Train"), NodePath("Ground/Rails1"), PackedStringArray("Transform", "Debug Shape", "curve"), NodePath("Ground/Rails1/Ballast"), PackedStringArray("Transform", "Geometry"), NodePath("Ground/Rails1/LRail"), PackedStringArray("polygon", "Transform"), NodePath("Ground/Rails1/RRail"), PackedStringArray("Transform", "polygon"), NodePath("Ground/Rails1/TrainEngine"), PackedStringArray("Transform"), NodePath("DirectionalLight3D"), PackedStringArray("Light", "Shadow"), NodePath("WorldEnvironment"), PackedStringArray("environment"), NodePath("TrainCamera"), PackedStringArray("Transform", "Camera")]
resource_unfolds=["res://scenes/train_control.tscn::PlaneMesh_23vqf", PackedStringArray(), "res://scenes/train_control.tscn::StandardMaterial3D_23vqf", PackedStringArray("Albedo"), "res://scenes/train_control.tscn::Curve3D_0b1nv", PackedStringArray("Up Vector", "point_count_array"), "res://scenes/train_control.tscn::StandardMaterial3D_ke0jj", PackedStringArray("UV1", "Transform"), "res://scenes/train_control.tscn::StandardMaterial3D_ihlg3", PackedStringArray("Roughness", "Metallic"), "res://scenes/train_control.tscn::Environment_jy5c4", PackedStringArray("Sky", "Ambient Light", "Fog", "Background"), "res://scenes/train_control.tscn::LabelSettings_1lqs8", PackedStringArray()] resource_unfolds=["res://scenes/train_control.tscn::PlaneMesh_23vqf", PackedStringArray(), "res://scenes/train_control.tscn::StandardMaterial3D_23vqf", PackedStringArray("Albedo"), "res://scenes/train_control.tscn::Curve3D_0b1nv", PackedStringArray("Up Vector"), "res://scenes/train_control.tscn::StandardMaterial3D_ke0jj", PackedStringArray("UV1", "Transform"), "res://scenes/train_control.tscn::StandardMaterial3D_ihlg3", PackedStringArray("Roughness", "Metallic"), "res://scenes/train_control.tscn::Curve3D_1lqs8", PackedStringArray(), "res://scenes/train_control.tscn::Environment_jy5c4", PackedStringArray("Sky", "Ambient Light", "Fog", "Background"), "res://scenes/train_control.tscn::LabelSettings_1lqs8", PackedStringArray()]
nodes_folded=[] nodes_folded=[]

View File

@@ -1,35 +1,11 @@
list=[{ list=[{
"base": &"Camera3D", "base": &"Node3D",
"class": &"TrainJourneyCamera", "class": &"Train",
"icon": "", "icon": "",
"is_abstract": false, "is_abstract": false,
"is_tool": false, "is_tool": false,
"language": &"GDScript", "language": &"GDScript",
"path": "res://scripts/trainjourney_camera.gd" "path": "res://scripts/train.gd"
}, {
"base": &"PathFollow3D",
"class": &"TrainEngine",
"icon": "",
"is_abstract": false,
"is_tool": false,
"language": &"GDScript",
"path": "res://scripts/engine.gd"
}, {
"base": &"Camera3D",
"class": &"TrainControlCamera",
"icon": "",
"is_abstract": false,
"is_tool": false,
"language": &"GDScript",
"path": "res://scripts/traincontrol_camera.gd"
}, {
"base": &"RefCounted",
"class": &"OBJLoader",
"icon": "",
"is_abstract": false,
"is_tool": false,
"language": &"GDScript",
"path": "res://scripts/objloader.gd"
}, { }, {
"base": &"Node3D", "base": &"Node3D",
"class": &"TrackGenerator", "class": &"TrackGenerator",
@@ -39,11 +15,43 @@ list=[{
"language": &"GDScript", "language": &"GDScript",
"path": "res://scripts/track_generator.gd" "path": "res://scripts/track_generator.gd"
}, { }, {
"base": &"Node3D", "base": &"RefCounted",
"class": &"Train", "class": &"OBJLoader",
"icon": "", "icon": "",
"is_abstract": false, "is_abstract": false,
"is_tool": false, "is_tool": false,
"language": &"GDScript", "language": &"GDScript",
"path": "res://scripts/train.gd" "path": "res://scripts/objloader.gd"
}, {
"base": &"Camera3D",
"class": &"TrainControlCamera",
"icon": "",
"is_abstract": false,
"is_tool": false,
"language": &"GDScript",
"path": "res://scripts/traincontrol_camera.gd"
}, {
"base": &"Camera3D",
"class": &"TrainJourneyCamera",
"icon": "",
"is_abstract": false,
"is_tool": false,
"language": &"GDScript",
"path": "res://scripts/trainjourney_camera.gd"
}, {
"base": &"MeshInstance3D",
"class": &"TrainBody",
"icon": "",
"is_abstract": false,
"is_tool": false,
"language": &"GDScript",
"path": "res://scripts/train_movement.gd"
}, {
"base": &"Area3D",
"class": &"RailSwitch",
"icon": "",
"is_abstract": false,
"is_tool": false,
"language": &"GDScript",
"path": "res://scripts/rail_switch.gd"
}] }]

Binary file not shown.

View File

@@ -7,6 +7,7 @@
[ext_resource type="ArrayMesh" uid="uid://cm8un80nubjbi" path="res://resources/train kit/train-diesel-a.obj" id="3_jy5c4"] [ext_resource type="ArrayMesh" uid="uid://cm8un80nubjbi" path="res://resources/train kit/train-diesel-a.obj" id="3_jy5c4"]
[ext_resource type="Script" uid="uid://b65vwus8xxmun" path="res://scripts/traincontrol_camera.gd" id="4_jy5c4"] [ext_resource type="Script" uid="uid://b65vwus8xxmun" path="res://scripts/traincontrol_camera.gd" id="4_jy5c4"]
[ext_resource type="Script" uid="uid://df2oi5vyeak81" path="res://scripts/train_movement.gd" id="6_1lqs8"] [ext_resource type="Script" uid="uid://df2oi5vyeak81" path="res://scripts/train_movement.gd" id="6_1lqs8"]
[ext_resource type="Script" uid="uid://b5x80gpkn1swt" path="res://scripts/rail_swtich.gd" id="7_cenvf"]
[sub_resource type="PlaneMesh" id="PlaneMesh_23vqf"] [sub_resource type="PlaneMesh" id="PlaneMesh_23vqf"]
size = Vector2(100, 100) size = Vector2(100, 100)
@@ -17,10 +18,10 @@ albedo_color = Color(2.153851e-06, 0.25305444, 0.03645257, 1)
[sub_resource type="Curve3D" id="Curve3D_0b1nv"] [sub_resource type="Curve3D" id="Curve3D_0b1nv"]
closed = true closed = true
_data = { _data = {
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, -41.962486, 0.03566742, -44.78871, 0, 0, 0, 0, 0, 0, -7.760188, 0.036315918, -45.60305, 0, 0, 0, 0, 0, 0, 21.603975, 0.03604126, -45.26774, 0, 0, 0, 0, 0, 0, 41.148148, 0.03127289, -39.27994, 0, 0, 0, 0, 0, 0, 44.2618, 0.02154541, -27.064838, 0, 0, 0, 0, 0, 0, 44.118095, 0.0033874512, -4.2633114, 0, 0, 0, 0, 0, 0, 26.96904, 0.003112793, -3.9279928, 0, 0, 0, 0, 0, 0, 3.4968712, 0.0079574585, -10.011598, 0, 0, 0, 0, 0, 0, -3.8321874, 0.024543762, -30.849133, 0, 0, 0, 0, 0, 0, -25.627771, 0.026069641, -32.765224, 0, 0, 0, 0, 0, 0, -31.28027, 0.015075684, -18.969343, 0, 0, 0, 0, 0, 0, -23.472174, 0.003479004, -4.4070177, 0, 0, 0, 0, 0, 0, 12.167218, -0.011207581, 14.035401, 0, 0, 0, 0, 0, 0, 34.681347, -0.013763428, 17.244862, 0, 0, 0, 0, 0, 0, 46.99225, -0.019981384, 25.052942, 0, 0, 0, 0, 0, 0, 42.72894, -0.03504944, 43.97439, 0, 0, 0, 0, 0, 0, 14.897652, -0.036231995, 45.459354, 0, 0, 0, 0, 0, 0, -23.088955, -0.034858704, 43.73488, 0, 0, 0, 0, 0, 0, -44.357616, -0.034965515, 43.878586, 0, 0, 0, 0, 0, 0, -45.603073, -0.010246277, 12.837832, 0, 0, 0, 0, 0, 0, -34.585533, 0.0079422, -10.0116005, 0, 0, 0, 0, 0, 0, -38.321926, 0.022087097, -27.78338), "points": PackedVector3Array(-2.1678085, -0.043792725, 1.658886, 2.1678085, 0.043792725, -1.658886, -41.962486, 0.03566742, -44.78871, 0, 0, 0, 0, 0, 0, -7.760188, 0.036315918, -45.60305, -6.559948, 0.007423401, -0.16356277, 6.559948, -0.007423401, 0.16356277, 21.603975, 0.03604126, -45.26774, -3.4513588, 0.124176025, -4.544277, 3.4513588, -0.124176025, 4.544277, 40.931072, 0.032211304, -40.35701, 0.5563507, 0.09750366, -3.6268482, -0.5563507, -0.09750366, 3.6268482, 45.43544, 0.021453857, -26.947992, 3.438774, 0.09018707, -3.405755, -3.438774, -0.09018707, 3.405755, 38.412643, 0.47789, -9.150471, 6.6514378, -0.022911072, 0.7331085, -6.6514378, 0.022911072, -0.7331085, 26.96904, 0.003112793, -3.9279928, 5.315757, -0.10071564, 3.6390858, -5.315757, 0.10071564, -3.6390858, 3.4968712, 0.0079574585, -10.011598, 4.9409637, -0.0754776, 2.709568, -4.9409637, 0.0754776, -2.709568, -3.8321874, 0.024543762, -30.849133, 6.360344, 0.0488739, -1.9223251, -6.360344, -0.0488739, 1.9223251, -22.311077, 0.005493164, -31.887383, -0.9378357, 0.12989807, -4.797656, 0.9378357, -0.12989807, 4.797656, -31.28027, 0.015075684, -18.969343, -7.12364, 0.096969604, -3.4738579, 7.12364, -0.096969604, 3.4738579, -23.472174, 0.003479004, -4.4070177, -9.224047, 0.08418274, -2.961853, 9.224047, -0.08418274, 2.961853, 12.167218, -0.011207581, 14.035401, -8.825874, 0.03265381, -1.0564928, 8.825874, -0.03265381, 1.0564928, 32.632145, -0.011894226, 14.993831, 0, 0, 0, 0, 0, 0, 39.98447, -0.019104004, 24.146927, 4.9879036, 0.122177124, -4.6163826, -4.9879036, -0.122177124, 4.6163826, 35.724655, 0.047676086, 33.444454, 8.1661625, 0.014076233, -0.6628723, -8.1661625, -0.014076233, 0.6628723, 11.495622, 0.0951767, 40.647045, 4.9570847, -0.058029175, 2.0650558, -4.9570847, 0.058029175, -2.0650558, -22.318954, 0.051948547, 40.504288, 4.9869003, -0.18069458, 6.610588, -4.9869003, 0.18069458, -6.610588, -37.494194, 0.080329895, 26.992659, -1.5943985, -0.19984436, 7.435757, 1.5943985, 0.19984436, -7.435757, -46.58226, 0.10346222, 8.63745, -0.4270401, -0.16287994, 6.045038, 0.4270401, 0.16287994, -6.045038, -39.930115, 0.050865173, -11.514841, 4.8086166, -0.20992279, 7.687052, -4.8086166, 0.20992279, -7.687052, -35.56163, 0.15759277, -32.8561, -0.73628235, -0.15232849, 5.656826, 0.73628235, 0.15232849, -5.656826, -45.566254, 1.1692886, -39.59991),
"tilts": PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) "tilts": PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
} }
point_count = 22 point_count = 23
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ke0jj"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ke0jj"]
albedo_texture = ExtResource("1_ihlg3") albedo_texture = ExtResource("1_ihlg3")
@@ -31,6 +32,14 @@ uv1_offset = Vector3(0, -0.61, 0)
metallic = 1.0 metallic = 1.0
roughness = 0.25 roughness = 0.25
[sub_resource type="Curve3D" id="Curve3D_1lqs8"]
closed = true
_data = {
"points": PackedVector3Array(-6.2964935, 0.06638336, -2.3570595, 6.2964935, -0.06638336, 2.3570595, 24, 0, -36, 0.40251923, 0.1432724, -5.316846, -0.40251923, -0.1432724, 5.316846, 30.535202, 0.016418457, -19.69652, -3.0211945, 0.21754456, -8.010609, 3.0211945, -0.21754456, 8.010609, 37.792625, 0.0013275146, -0.5123644, 7.037945, 0.16593933, -6.2738285, -7.037945, -0.16593933, 6.2738285, 33.177887, 0.0013427734, 21.921793, 12.049584, -0.0362854, 1.1334801, -12.049584, 0.0362854, -1.1334801, 7.185522, 0.0013427734, 33.84686, 3.006013, -0.23966217, 8.824167, -3.006013, 0.23966217, -8.824167, -5.633688, 0.0127334595, 16.86435, 0.09129143, -0.14064789, 5.2124147, -0.09129143, 0.14064789, -5.2124147, -20.520624, 0.0013427734, -3.9991686, -6.1595325, -0.18273163, 6.8687496, 6.1595325, 0.18273163, -6.8687496, -10.095118, 0.0013427734, -27.90497),
"tilts": PackedFloat32Array(0, 0, 0, 0, 0, 0, 0, 0)
}
point_count = 8
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_jgp6u"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_jgp6u"]
sky_top_color = Color(0.6262097, 0.76737565, 0.9309246, 1) sky_top_color = Color(0.6262097, 0.76737565, 0.9309246, 1)
sky_horizon_color = Color(0.82665706, 0.8808251, 0.95468724, 1) sky_horizon_color = Color(0.82665706, 0.8808251, 0.95468724, 1)
@@ -63,10 +72,18 @@ main_scene = ExtResource("2_0b1nv")
mesh = SubResource("PlaneMesh_23vqf") mesh = SubResource("PlaneMesh_23vqf")
surface_material_override/0 = SubResource("StandardMaterial3D_23vqf") surface_material_override/0 = SubResource("StandardMaterial3D_23vqf")
[node name="Rails" type="Path3D" parent="Ground" unique_id=1160818899] [node name="Train" type="MeshInstance3D" parent="Ground" unique_id=65189673 node_paths=PackedStringArray("rail_a", "rail_b")]
transform = Transform3D(0.6867333, -0.014397784, -0.89729905, 0, 1.1300678, -0.018126683, 0.8974134, 0.011017708, 0.68664587, -41.962486, 0.03566742, -44.78871)
mesh = ExtResource("3_jy5c4")
skeleton = NodePath("../Rails1/TrainEngine")
script = ExtResource("6_1lqs8")
rail_a = NodePath("../Rails1")
rail_b = NodePath("../Rails2")
[node name="Rails1" type="Path3D" parent="Ground" unique_id=1160818899]
curve = SubResource("Curve3D_0b1nv") curve = SubResource("Curve3D_0b1nv")
[node name="Ballast" type="CSGPolygon3D" parent="Ground/Rails" unique_id=259312931] [node name="Ballast" type="CSGPolygon3D" parent="Ground/Rails1" unique_id=259312931]
polygon = PackedVector2Array(-1, 0, -1, 0.1, 1, 0.1, 1, 0) polygon = PackedVector2Array(-1, 0, -1, 0.1, 1, 0.1, 1, 0)
mode = 2 mode = 2
path_node = NodePath("..") path_node = NodePath("..")
@@ -81,7 +98,7 @@ path_u_distance = 1.0
path_joined = true path_joined = true
material = SubResource("StandardMaterial3D_ke0jj") material = SubResource("StandardMaterial3D_ke0jj")
[node name="LRail" type="CSGPolygon3D" parent="Ground/Rails" unique_id=477776682] [node name="LRail" type="CSGPolygon3D" parent="Ground/Rails1" unique_id=477776682]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.24889, -4.7985353, 2.2341003) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.24889, -4.7985353, 2.2341003)
polygon = PackedVector2Array(-0.5, 0, -0.5, 0.2, -0.4, 0.2, -0.4, 0) polygon = PackedVector2Array(-0.5, 0, -0.5, 0.2, -0.4, 0.2, -0.4, 0)
mode = 2 mode = 2
@@ -97,7 +114,7 @@ path_u_distance = 1.0
path_joined = true path_joined = true
material = SubResource("StandardMaterial3D_ihlg3") material = SubResource("StandardMaterial3D_ihlg3")
[node name="RRail" type="CSGPolygon3D" parent="Ground/Rails" unique_id=965437995] [node name="RRail" type="CSGPolygon3D" parent="Ground/Rails1" unique_id=965437995]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.24889, -4.7985353, 2.2341003) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.24889, -4.7985353, 2.2341003)
polygon = PackedVector2Array(0.5, 0, 0.5, 0.2, 0.4, 0.2, 0.5, 0) polygon = PackedVector2Array(0.5, 0, 0.5, 0.2, 0.4, 0.2, 0.5, 0)
mode = 2 mode = 2
@@ -113,14 +130,71 @@ path_u_distance = 1.0
path_joined = true path_joined = true
material = SubResource("StandardMaterial3D_ihlg3") material = SubResource("StandardMaterial3D_ihlg3")
[node name="TrainEngine" type="PathFollow3D" parent="Ground/Rails" unique_id=973990755] [node name="TrainEngine" type="PathFollow3D" parent="Ground/Rails1" unique_id=973990755]
transform = Transform3D(0.026897233, -2.1416474e-05, -1.1296921, 0, 1.130161, -2.141972e-05, 1.1296905, 5.0991304e-07, 0.02689727, -41.962486, 0.03566742, -44.78871) transform = Transform3D(0.6867333, -0.014397784, -0.89729905, 0, 1.1300678, -0.018126683, 0.8974134, 0.011017708, 0.68664587, -41.962486, 0.03566742, -44.78871)
rotation_mode = 4 rotation_mode = 4
script = ExtResource("2_jgp6u") script = ExtResource("2_jgp6u")
[node name="Train" type="MeshInstance3D" parent="Ground/Rails/TrainEngine" unique_id=65189673] [node name="Rails2" type="Path3D" parent="Ground" unique_id=1426938039]
mesh = ExtResource("3_jy5c4") curve = SubResource("Curve3D_1lqs8")
script = ExtResource("6_1lqs8")
[node name="Ballast" type="CSGPolygon3D" parent="Ground/Rails2" unique_id=608449521]
polygon = PackedVector2Array(-1, 0, -1, 0.1, 1, 0.1, 1, 0)
mode = 2
path_node = NodePath("..")
path_interval_type = 0
path_interval = 1.0
path_simplify_angle = 0.0
path_rotation = 2
path_rotation_accurate = false
path_local = false
path_continuous_u = true
path_u_distance = 1.0
path_joined = true
material = SubResource("StandardMaterial3D_ke0jj")
[node name="RRail" type="CSGPolygon3D" parent="Ground/Rails2" unique_id=469196308]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.24889, -4.7985353, 2.2341003)
polygon = PackedVector2Array(0.5, 0, 0.5, 0.2, 0.4, 0.2, 0.5, 0)
mode = 2
path_node = NodePath("..")
path_interval_type = 0
path_interval = 1.0
path_simplify_angle = 0.0
path_rotation = 2
path_rotation_accurate = false
path_local = false
path_continuous_u = true
path_u_distance = 1.0
path_joined = true
material = SubResource("StandardMaterial3D_ihlg3")
[node name="LRail" type="CSGPolygon3D" parent="Ground/Rails2" unique_id=1887208549]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.24889, -4.7985353, 2.2341003)
polygon = PackedVector2Array(-0.5, 0, -0.5, 0.2, -0.4, 0.2, -0.4, 0)
mode = 2
path_node = NodePath("..")
path_interval_type = 0
path_interval = 1.0
path_simplify_angle = 0.0
path_rotation = 2
path_rotation_accurate = false
path_local = false
path_continuous_u = true
path_u_distance = 1.0
path_joined = true
material = SubResource("StandardMaterial3D_ihlg3")
[node name="TrainEngine" type="PathFollow3D" parent="Ground/Rails2" unique_id=1618605131]
transform = Transform3D(-0.39616987, 0.010450672, -1.0582525, 0, 1.1301593, 0.01115706, 1.0583019, 0.003912155, -0.3961513, 24, 0, -36)
rotation_mode = 4
script = ExtResource("2_jgp6u")
[node name="RailSwtich" type="Area3D" parent="Ground" unique_id=1897237029 node_paths=PackedStringArray("rail_a", "rail_b", "switch_to_rail")]
script = ExtResource("7_cenvf")
rail_a = NodePath("../Rails1")
rail_b = NodePath("../Rails2")
switch_to_rail = NodePath("../Rails1")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=1729725358] [node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=1729725358]
shadow_enabled = true shadow_enabled = true
@@ -135,7 +209,7 @@ current = true
fov = 11.9 fov = 11.9
near = 0.001 near = 0.001
script = ExtResource("4_jy5c4") script = ExtResource("4_jy5c4")
train = NodePath("../Ground/Rails/TrainEngine/Train") train = NodePath("../Ground/Train")
[node name="HUD" type="Control" parent="." unique_id=563257159] [node name="HUD" type="Control" parent="." unique_id=563257159]
layout_mode = 3 layout_mode = 3
@@ -174,6 +248,6 @@ text = "Comandi:
\"W / S - Accelera / Rallenta\", \"W / S - Accelera / Rallenta\",
\"A / D - Ruota camera\", \"A / D - Ruota camera\",
\"SPACE - Cambia camera\", \"SPACE - Cambia camera\",
\"TAB - Cambia treno\", \"TAB\" - Cambia binario,
\"ESC - Esci\"" \"ESC - Esci\""
label_settings = SubResource("LabelSettings_1lqs8") label_settings = SubResource("LabelSettings_1lqs8")

View File

@@ -1,9 +1,9 @@
extends PathFollow3D extends PathFollow3D
class_name TrainEngine #class_name TrainEngine
#
@onready var train: MeshInstance3D = $Train #@onready var train: MeshInstance3D = $"../../Train"
#
#
func _physics_process(delta: float) -> void: #func _physics_process(delta: float) -> void:
if train: #if train:
progress += train.current_speed * delta #progress += train.current_speed * delta

17
scripts/rail_switch.gd Normal file
View File

@@ -0,0 +1,17 @@
extends Area3D
class_name RailSwitch
@export var rail_a: Path3D
@export var rail_b: Path3D
@export var switch_to_rail: Path3D # Il binario verso cui deviare
# Cambia direzione dello scambio
func toggle_switch() -> void:
if switch_to_rail == rail_a:
switch_to_rail = rail_b
else:
switch_to_rail = rail_a
func _on_body_entered(body: Node3D) -> void:
if body is Train:
body.switch_to_rail(switch_to_rail)

View File

@@ -0,0 +1 @@
uid://bhan6tvt4sow

14
scripts/rail_swtich.gd Normal file
View File

@@ -0,0 +1,14 @@
extends Area3D
@export var rail_a: Path3D
@export var rail_b: Path3D
@export var switch_to_rail: Path3D # Il binario verso cui deviare
# Cambia direzione dello scambio
func toggle_switch() -> void:
if switch_to_rail == rail_a:
switch_to_rail = rail_b
else:
switch_to_rail = rail_a

View File

@@ -0,0 +1 @@
uid://b5x80gpkn1swt

View File

@@ -1,21 +1,29 @@
extends MeshInstance3D extends MeshInstance3D
class_name TrainBody
signal speed_changed(new_speed: float) signal speed_changed(new_speed: float)
signal rail_switched(old_rail: Path3D, new_rail: Path3D)
@export_group("Train") @export_group("Train")
@export var base_speed: float = 15.0 @export var base_speed: float = 15.0
@export var max_speed: float = 50.0 @export var max_speed: float = 50.0
@export var min_speed: float = 3.0 @export var min_speed: float = 3.0
@export var acceleration: float = 12.0 @export var acceleration: float = 12.0
@export var rail_a: Path3D
@export var rail_b: Path3D
var current_follower: PathFollow3D
var current_rail: Path3D
var current_speed: float = 15.0 var current_speed: float = 15.0
func _ready() -> void: func _ready() -> void:
current_speed = base_speed current_speed = base_speed
switch_to_rail(rail_a)
func _process(delta: float) -> void: func _process(delta: float) -> void:
_handle_input(delta) _handle_input(delta)
current_follower.progress += current_speed * delta
func _handle_input(delta: float) -> void: func _handle_input(delta: float) -> void:
@@ -29,3 +37,35 @@ func _handle_input(delta: float) -> void:
func get_speed() -> float: func get_speed() -> float:
return current_speed return current_speed
func switch_to_rail(new_rail: Path3D) -> void:
if new_rail == current_rail:
return
current_rail = new_rail
current_follower = new_rail.get_node("TrainEngine") as PathFollow3D
var closest_offset = find_closest_point_on_path(new_rail, global_position)
current_follower.progress = closest_offset
func find_closest_point_on_path(path: Path3D, point: Vector3) -> float:
var curve = path.curve
var closest_offset = 0.0
var min_distance = INF
var length = curve.get_baked_length()
var steps = 100 # Più alto = più preciso ma più lento
for i in range(steps + 1):
var offset = (float(i) / steps) * length
# Trasforma il punto locale della curva in coordinate globali
var path_point = path.global_transform * curve.sample_baked(offset)
var dist = point.distance_to(path_point)
if dist < min_distance:
min_distance = dist
closest_offset = offset
return closest_offset

View File

@@ -3,9 +3,9 @@ extends Node3D
@onready var speed_label : Label = $HUD/speed_label @onready var speed_label : Label = $HUD/speed_label
@onready var camera_label : Label = $HUD/camera_label @onready var camera_label : Label = $HUD/camera_label
@onready var train: MeshInstance3D = $Ground/Rails/TrainEngine/Train @onready var train: MeshInstance3D = $Ground/Train
@onready var camera: TrainControlCamera = $TrainCamera @onready var camera: TrainControlCamera = $TrainCamera
func _process(_delta: float) -> void: func _process(_delta: float) -> void:
_update_ui() _update_ui()
@@ -13,6 +13,8 @@ func _process(_delta: float) -> void:
if Input.is_action_just_pressed("ui_cancel"): if Input.is_action_just_pressed("ui_cancel"):
SceneSwitcher.switch_scene(main_scene.resource_path) SceneSwitcher.switch_scene(main_scene.resource_path)
if Input.is_action_just_pressed("change_train"):
SceneSwitcher.switch_scene(main_scene.resource_path)
func _update_ui() -> void: func _update_ui() -> void: