switch
This commit is contained in:
17
scripts/rail_switch.gd
Normal file
17
scripts/rail_switch.gd
Normal 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)
|
||||
Reference in New Issue
Block a user