Rollercoaster-Derivatives/Cart/cart.gd
2026-03-14 12:08:16 -07:00

26 lines
428 B
GDScript

extends Node2D
class_name Cart
@export var spline : Spline
var going = false
var progress = 0
func _ready():
hide()
func _process(delta: float) -> void:
if len(spline.curve_points) > 1:
position = spline.curve_points[progress]
rotation = (spline.curve_points[progress+1] - position).angle()
if not going:
return
progress += 1
if progress >= len(spline.curve_points)-1:
going = false
hide()
progress = 0