2019-12-19 21:24:40 +01:00
|
|
|
class_name GSTLookWhereYouGo
|
2020-01-16 23:14:50 +01:00
|
|
|
extends GSTMatchOrientation
|
2020-01-02 23:42:41 +01:00
|
|
|
# Calculates an angular acceleration to match an agent's orientation to its direction of travel.
|
2019-12-19 21:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
func _init(agent: GSTSteeringAgent).(agent, null) -> void:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
func _calculate_steering(accel: GSTTargetAcceleration) -> GSTTargetAcceleration:
|
|
|
|
if agent.linear_velocity.length_squared() < agent.zero_linear_speed_threshold:
|
|
|
|
accel.set_zero()
|
|
|
|
return accel
|
|
|
|
else:
|
2020-01-27 18:57:51 +01:00
|
|
|
var orientation := GSTUtils.vector_to_angle(agent.linear_velocity)
|
2019-12-19 21:24:40 +01:00
|
|
|
return _match_orientation(accel, orientation)
|