aboutsummaryrefslogtreecommitdiffstats
path: root/Scripts/scene_control.gd
diff options
context:
space:
mode:
authorLibravatar perivesta <>2023-07-08 11:40:53 +0200
committerLibravatar perivesta <>2023-07-08 11:40:53 +0200
commit892ed4854bcccbac546f5ac32c0c5fa0245f5fa7 (patch)
tree6c3403e1734790c48a90741e62e0369301b1e06a /Scripts/scene_control.gd
parenta10d0e582a9a614b933f3e689592595e6438513e (diff)
download2023-892ed4854bcccbac546f5ac32c0c5fa0245f5fa7.tar.gz
2023-892ed4854bcccbac546f5ac32c0c5fa0245f5fa7.tar.bz2
2023-892ed4854bcccbac546f5ac32c0c5fa0245f5fa7.zip
draw a path for car to follow
Diffstat (limited to 'Scripts/scene_control.gd')
-rw-r--r--Scripts/scene_control.gd17
1 files changed, 12 insertions, 5 deletions
diff --git a/Scripts/scene_control.gd b/Scripts/scene_control.gd
index 9f231e0..fdaad14 100644
--- a/Scripts/scene_control.gd
+++ b/Scripts/scene_control.gd
@@ -2,12 +2,19 @@ extends Node
class_name SceneControl
-@onready var path : Path2D = $Path2D
-
-@on#ready var path_follow : PathFollow2D = $Path2D/PathFollow2D
-
+@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.h_offset = offset
+ 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