using Godot; using System.Linq; public partial class RangedEnemy : BasicEnemy { public override void _Process(double delta) { var players = GetTree().GetNodesInGroup("Player"); if (players.Any()) { var convertedPlayers = players.Select(x => (Node3D)x); var target = convertedPlayers.OrderBy(x => Position.DistanceTo(x.Position)).FirstOrDefault(); var hitBox = GetNode("CharacterBody").GetChildren().OfType().Single(); hitBox.LookAt(target.Position, Vector3.Up); hitBox.Rotation = new Vector3(0, hitBox.Rotation.Y, hitBox.Rotation.Z); } } }