mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-31 00:11:54 +08:00
11 lines
379 B
GDScript
11 lines
379 B
GDScript
class_name PresetEntityAI
|
|
|
|
static func follow(entity: EntityBase, target: EntityBase, minDistance: float = 100):
|
|
var delta = target.position - entity.position
|
|
var distanceOffset = abs(delta.length() - minDistance)
|
|
if distanceOffset > entity.fields[FieldStore.Entity.MOVEMENT_SPEED] * 10:
|
|
if delta.length() < minDistance:
|
|
entity.move(-delta)
|
|
else:
|
|
entity.move(delta)
|