aboutsummaryrefslogtreecommitdiffstats
path: root/Scripts/scene_control.gd
blob: fdaad14ef820d44d5bef07d00b3e627a08b432ee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
extends Node

class_name SceneControl

@onready var path : Path2D = $DrawNode/TrackPath
@onready var path_follow : PathFollow2D = $DrawNode/TrackPath/TrackFollower
@onready var car : StaticBody2D = $Car

func get_path_direction(pos):
	var offset = path.curve.get_closest_offset(pos)
	path_follow.progress = offset
	return path_follow.transform.x

func get_path_next_position(pos):
	var offset = path.curve.get_closest_offset(pos)
	path_follow.progress = offset + 50
	return path_follow.position

func set_driving(driving: bool):
	car.driving = driving