2020-01-16 09:44:44 +01:00
|
|
|
extends KinematicBody2D
|
|
|
|
|
|
|
|
|
2020-02-06 22:29:48 +01:00
|
|
|
var agent := GSTKinematicBody2DAgent.new(self)
|
2020-01-16 09:44:44 +01:00
|
|
|
var target := GSTAgentLocation.new()
|
|
|
|
var arrive := GSTArrive.new(agent, target)
|
|
|
|
var _accel := GSTTargetAcceleration.new()
|
|
|
|
|
|
|
|
var _velocity := Vector2()
|
|
|
|
var _drag := 0.1
|
|
|
|
|
|
|
|
|
|
|
|
func _physics_process(delta: float) -> void:
|
2020-02-06 20:46:21 +01:00
|
|
|
arrive.calculate_steering(_accel)
|
2020-02-07 15:15:03 +01:00
|
|
|
agent._apply_steering(_accel, delta)
|
2020-01-16 09:44:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
func setup(
|
2020-01-22 17:55:49 +01:00
|
|
|
linear_speed_max: float,
|
|
|
|
linear_acceleration_max: float,
|
2020-01-16 09:44:44 +01:00
|
|
|
arrival_tolerance: float,
|
|
|
|
deceleration_radius: float
|
|
|
|
) -> void:
|
2020-01-22 17:55:49 +01:00
|
|
|
agent.linear_speed_max = linear_speed_max
|
|
|
|
agent.linear_acceleration_max = linear_acceleration_max
|
2020-02-06 20:54:12 +01:00
|
|
|
agent.linear_drag_percentage = _drag
|
2020-01-16 09:44:44 +01:00
|
|
|
arrive.deceleration_radius = deceleration_radius
|
|
|
|
arrive.arrival_tolerance = arrival_tolerance
|
|
|
|
target.position = agent.position
|