15 lines
418 B
GDScript
15 lines
418 B
GDScript
extends Node3D
|
|
|
|
var player: Node3D = null
|
|
|
|
func _process(delta: float) -> void:
|
|
# If we don't have the player yet, try to find them in the group
|
|
if not is_instance_valid(player):
|
|
var players = get_tree().get_nodes_in_group("player")
|
|
if players.size() > 0:
|
|
player = players[0] as Node3D
|
|
|
|
# If the player exists, follow their position
|
|
if is_instance_valid(player):
|
|
global_position = player.global_position
|