godot-steering-ai-framework/project/demos/arrive/ArriveDemo.gd

38 lines
1.1 KiB
GDScript3
Raw Normal View History

2019-12-21 03:32:02 +01:00
extends Node2D
onready var target: = $Target
onready var arriver: = $Arriver
onready var gui: = $GUI
2019-12-22 20:23:25 +01:00
func _ready() -> void:
gui.connect("align_tolerance_changed", self, "_on_GUI_align_tolerance_changed")
gui.connect("decel_radius_changed", self, "_on_GUI_decel_radius_changed")
gui.connect("max_speed_changed", self, "_on_GUI_max_speed_changed")
gui.connect("max_accel_changed", self, "_on_GUI_max_accel_changed")
gui.max_speed.text = str(arriver._agent.max_linear_speed)
gui.max_accel.text = str(arriver._agent.max_linear_acceleration)
gui.arrival_tolerance.text = str(arriver._arrive.arrival_tolerance)
gui.deceleration_radius.text = str(arriver._arrive.deceleration_radius)
2019-12-21 03:32:02 +01:00
func draw(location: Vector2) -> void:
target.draw(location)
2019-12-22 20:23:25 +01:00
func _on_GUI_align_tolerance_changed(value: int) -> void:
arriver._arrive.arrival_tolerance = value
2019-12-22 20:23:25 +01:00
func _on_GUI_decel_radius_changed(value: int) -> void:
arriver._arrive.deceleration_radius = value
2019-12-22 20:23:25 +01:00
func _on_GUI_max_speed_changed(value: int) -> void:
arriver._agent.max_linear_speed = value
2019-12-22 20:23:25 +01:00
func _on_GUI_max_accel_changed(value: int) -> void:
arriver._agent.max_linear_acceleration = value