godot-steering-ai-framework/project/src/behaviors/GSTFlee.gd

18 lines
462 B
GDScript3
Raw Normal View History

extends GSTSeek
class_name GSTFlee
"""
Calculates acceleration to take an agent directly away from a target agent.
"""
func _init(agent: GSTSteeringAgent, target: GSTAgentLocation).(agent, target) -> void:
pass
func _calculate_steering(acceleration: GSTTargetAcceleration) -> GSTTargetAcceleration:
acceleration.linear = (
(agent.position - target.position).normalized() * agent.max_linear_acceleration)
acceleration.angular = 0
return acceleration