speedin-santa/Scripts/SleighController.gd
2024-12-18 16:35:26 -05:00

25 lines
724 B
GDScript

class_name Sleigh extends Node3D
static var instance: Sleigh
@export var baseSpeed: float = 100
@export var maxSpeed: float = 500
@export var drag: float = 10
var speed: float
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
speed = baseSpeed
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
var distance: float = (speed * delta * Vector3.FORWARD).z
position.z += distance
if (is_instance_valid(City.instance)): City.instance.distance -= distance
speed -= drag * delta
speed = clampf(speed, baseSpeed, maxSpeed)
func _on_rudolph_entered(area: Area3D) -> void:
if (area is SpeedRing):
speed *= area.strength