2019-12-19 20:04:08 +01:00
|
|
|
class_name GSTSeek
|
2020-01-16 23:14:50 +01:00
|
|
|
extends GSTSteeringBehavior
|
2020-01-02 23:42:41 +01:00
|
|
|
# Calculates acceleration to take an agent to a target agent's position as directly as possible
|
2019-12-19 20:04:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
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
|