diff options
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) |