mirror of
https://github.com/Relintai/godot-steering-ai-framework.git
synced 2025-01-01 13:49:49 +01:00
21 lines
531 B
GDScript3
21 lines
531 B
GDScript3
|
extends GSTSteeringBehavior
|
||
|
class_name GSTSeek
|
||
|
"""
|
||
|
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
|