mirror of
https://github.com/Relintai/godot-steering-ai-framework.git
synced 2024-11-14 04:57:19 +01:00
8fb4f4c51a
The use of multiline blocks in GDSCript for comments leaves them in the final compiled file, increasing size and potentially processing for no end-user gain.
17 lines
551 B
GDScript
17 lines
551 B
GDScript
extends GSTMatchOrientation
|
|
class_name GSTLookWhereYouGo
|
|
# 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: = atan2(agent.linear_velocity.x, -agent.linear_velocity.y)
|
|
return _match_orientation(accel, orientation)
|