diff options
author | perivesta <> | 2023-07-08 11:40:53 +0200 |
---|---|---|
committer | perivesta <> | 2023-07-08 11:40:53 +0200 |
commit | 892ed4854bcccbac546f5ac32c0c5fa0245f5fa7 (patch) | |
tree | 6c3403e1734790c48a90741e62e0369301b1e06a /Scripts/car_behaviour.gd | |
parent | a10d0e582a9a614b933f3e689592595e6438513e (diff) | |
download | 2023-892ed4854bcccbac546f5ac32c0c5fa0245f5fa7.tar.gz 2023-892ed4854bcccbac546f5ac32c0c5fa0245f5fa7.tar.bz2 2023-892ed4854bcccbac546f5ac32c0c5fa0245f5fa7.zip |
draw a path for car to follow
Diffstat (limited to 'Scripts/car_behaviour.gd')
-rw-r--r-- | Scripts/car_behaviour.gd | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Scripts/car_behaviour.gd b/Scripts/car_behaviour.gd index b71ebb6..afbc32f 100644 --- a/Scripts/car_behaviour.gd +++ b/Scripts/car_behaviour.gd @@ -5,6 +5,7 @@ extends StaticBody2D @export var steer_force = 0.1 @export var look_ahead = 75 @export var num_rays = 32 +@export var driving = false # context array var ray_directions = [] @@ -28,6 +29,9 @@ func _ready(): func _physics_process(delta): + if not driving: + return + set_interest() set_danger() choose_direction() @@ -38,8 +42,12 @@ func _physics_process(delta): func set_interest(): # Set interest in each slot based on world direction - if owner and owner.has_method("get_path_direction"): - var path_direction = owner.get_path_direction(position) +# if owner and owner.has_method("get_path_direction"): + if owner and owner.has_method("get_path_next_position"): +# var path_direction = owner.get_path_direction(position) + var next_pos = owner.get_path_next_position(position) + var path_direction = (next_pos - position).normalized() + for i in num_rays: var d = ray_directions[i].rotated(rotation).dot(path_direction) interest[i] = max(0, d) |