add distance_menu_world and fix rail generation
This commit is contained in:
@@ -50,10 +50,14 @@ enum TrainFacingDirection { KEEP_PATH_DIRECTION, LOCOMOTIVE_LEFT, LOCOMOTIVE_RIG
|
||||
@export_enum("keep_path_direction", "locomotive_left", "locomotive_right") var train_facing_direction: int = TrainFacingDirection.KEEP_PATH_DIRECTION
|
||||
|
||||
@export_group("Rails Bulding")
|
||||
##if true builds visible rail pieces along the Path3D
|
||||
@export var build_track_visuals: bool = true
|
||||
##distance between sleepers of the rails
|
||||
@export var sleepers_distance: float = 1.0
|
||||
##nodel for the sleeper of the rail
|
||||
@export var sleepers_model: PackedScene
|
||||
##if true add procedural rail bars even when sleepers_model is assigned
|
||||
@export var add_procedural_rails_to_sleepers_model: bool = false
|
||||
|
||||
@export_group("Manual Controls")
|
||||
##max speed
|
||||
@@ -115,7 +119,8 @@ func _ready() -> void:
|
||||
_initial_is_inmotion = is_inmotion
|
||||
|
||||
if curve != null and curve.get_baked_length() > 0:
|
||||
build_rails()
|
||||
if build_track_visuals:
|
||||
build_rails()
|
||||
build_train()
|
||||
_plan_stops()
|
||||
_apply_initial_train_start()
|
||||
@@ -258,6 +263,7 @@ func build_rails() -> void:
|
||||
|
||||
var total_length = curve.get_baked_length()
|
||||
var piece_number = int(total_length / sleepers_distance)
|
||||
var should_add_procedural_rails: bool = sleepers_model == null or add_procedural_rails_to_sleepers_model
|
||||
|
||||
for i in range(piece_number):
|
||||
var distance = i * sleepers_distance
|
||||
@@ -289,17 +295,18 @@ func build_rails() -> void:
|
||||
sleeper.material_override = mat_wood
|
||||
rail_piece.add_child(sleeper)
|
||||
|
||||
var rail_sx = MeshInstance3D.new()
|
||||
rail_sx.mesh = mesh_rail
|
||||
rail_sx.material_override = mat_iron
|
||||
rail_sx.position = Vector3(-rail_distance / 2.0, 0.1, 0)
|
||||
rail_piece.add_child(rail_sx)
|
||||
|
||||
var rail_dx = MeshInstance3D.new()
|
||||
rail_dx.mesh = mesh_rail
|
||||
rail_dx.material_override = mat_iron
|
||||
rail_dx.position = Vector3(rail_distance / 2.0, 0.1, 0)
|
||||
rail_piece.add_child(rail_dx)
|
||||
if should_add_procedural_rails:
|
||||
var rail_sx = MeshInstance3D.new()
|
||||
rail_sx.mesh = mesh_rail
|
||||
rail_sx.material_override = mat_iron
|
||||
rail_sx.position = Vector3(-rail_distance / 2.0, 0.1, 0)
|
||||
rail_piece.add_child(rail_sx)
|
||||
|
||||
var rail_dx = MeshInstance3D.new()
|
||||
rail_dx.mesh = mesh_rail
|
||||
rail_dx.material_override = mat_iron
|
||||
rail_dx.position = Vector3(rail_distance / 2.0, 0.1, 0)
|
||||
rail_piece.add_child(rail_dx)
|
||||
|
||||
func _plan_stops() -> void:
|
||||
stop_offset.clear()
|
||||
|
||||
Reference in New Issue
Block a user