mirror of
https://github.com/Relintai/godot-steering-ai-framework.git
synced 2025-01-05 17:59:39 +01:00
17 lines
542 B
GDScript
17 lines
542 B
GDScript
class_name GSTLookWhereYouGo
|
|
extends GSTMatchOrientation
|
|
# Calculates an angular acceleration to match an agent's orientation to its direction of travel.
|
|
|
|
|
|
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:
|
|
var orientation := GSTUtils.vector_to_angle(agent.linear_velocity)
|
|
return _match_orientation(accel, orientation)
|