2020-01-29 17:04:04 +01:00
|
|
|
# Calculates an acceleration to take an agent to a target agent's position
|
|
|
|
# directly.
|
2020-02-11 18:33:25 +01:00
|
|
|
class_name GSAISeek
|
|
|
|
extends GSAISteeringBehavior
|
2019-12-19 20:04:08 +01:00
|
|
|
|
|
|
|
|
2020-01-29 17:04:04 +01:00
|
|
|
# The target that the behavior aims to move the agent to.
|
2020-02-11 18:33:25 +01:00
|
|
|
var target: GSAIAgentLocation
|
2019-12-19 20:04:08 +01:00
|
|
|
|
|
|
|
|
2020-02-11 18:33:25 +01:00
|
|
|
func _init(agent: GSAISteeringAgent, target: GSAIAgentLocation).(agent) -> void:
|
2019-12-19 20:04:08 +01:00
|
|
|
self.target = target
|
|
|
|
|
|
|
|
|
2020-02-11 18:33:25 +01:00
|
|
|
func _calculate_steering(acceleration: GSAITargetAcceleration) -> void:
|
2019-12-19 20:04:08 +01:00
|
|
|
acceleration.linear = (
|
2020-01-22 17:55:49 +01:00
|
|
|
(target.position - agent.position).normalized() * agent.linear_acceleration_max)
|
2019-12-19 20:04:08 +01:00
|
|
|
acceleration.angular = 0
|