mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-12-28 13:27:10 +01:00
20 lines
544 B
GDScript3
20 lines
544 B
GDScript3
|
# Calculates an acceleration to take an agent to a target agent's position
|
||
|
# directly.
|
||
|
class_name GSAISeek
|
||
|
extends GSAISteeringBehavior
|
||
|
|
||
|
# 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
|