godot-steering-ai-framework/godot/addons/com.gdquest.godot-steering-ai-framework/Behaviors/GSAISeek.gd

18 lines
575 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.
2020-04-03 02:31:59 +02:00
# @category - Individual behaviors
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