godot-steering-ai-framework/project/src/Behaviors/GSAIFlee.gd

17 lines
457 B
GDScript3
Raw Normal View History

# Calculates acceleration to take an agent directly away from a target agent.
2020-02-22 18:48:58 +01:00
# category: Individual behaviors
class_name GSAIFlee
extends GSAISeek
func _init(agent: GSAISteeringAgent, target: GSAIAgentLocation).(agent, target) -> void:
pass
func _calculate_steering(acceleration: GSAITargetAcceleration) -> void:
acceleration.linear = (
(agent.position - target.position).normalized()
* agent.linear_acceleration_max
)
acceleration.angular = 0