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

19 lines
540 B
GDScript3
Raw Normal View History

2020-01-29 17:04:04 +01:00
# Calculates an acceleration to take an agent to a target agent's position
# directly.
class_name GSAISeek
extends GSAISteeringBehavior
2020-01-29 17:04:04 +01:00
# The target that the behavior aims to move the agent to.
var target: GSAIAgentLocation
func _init(agent: GSAISteeringAgent, target: GSAIAgentLocation).(agent) -> void:
self.target = target
func _calculate_steering(acceleration: GSAITargetAcceleration) -> void:
acceleration.linear = (
(target.position - agent.position).normalized() * agent.linear_acceleration_max)
acceleration.angular = 0