fml-avs/scenes/kreb.gd

21 lines
636 B
GDScript3
Raw Normal View History

2024-12-23 12:35:12 -05:00
extends Node3D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
2024-12-23 13:08:53 -05:00
func _process(_delta: float) -> void:
2024-12-23 12:35:12 -05:00
var closest: Node3D
var least_dist = INF
for p: Node3D in get_tree().get_nodes_in_group('players'):
var dist = global_position.distance_to(p.global_position)
if dist < least_dist:
least_dist = dist
closest = p
if closest:
look_at(closest.global_position * Vector3(1, 0, 1) + Vector3(0, 1, 0), Vector3.UP, true)