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

19 lines
525 B
GDScript3
Raw Normal View History

class_name GSTSeek
2020-01-16 23:14:50 +01:00
extends GSTSteeringBehavior
# Calculates acceleration to take an agent to a target agent's position as directly as possible
var target: GSTAgentLocation
func _init(agent: GSTSteeringAgent, target: GSTAgentLocation).(agent) -> void:
self.target = target
func _calculate_steering(acceleration: GSTTargetAcceleration) -> GSTTargetAcceleration:
acceleration.linear = (
(target.position - agent.position).normalized() * agent.max_linear_acceleration)
acceleration.angular = 0
return acceleration