using Godot; using System; public partial class EnemyMovement : Node { [Export] private NavigationAgent2D _agent2D; [Export] private CharacterBody2D _body2D; [Export] private float _speed; private double _time = 0; public override void _PhysicsProcess(double delta) { _time += delta; if (_time > 0.2) { _time = 0; _agent2D.SetTargetPosition(GameController.Instance.Player.GlobalPosition); } // _parent.Position = _agent2D.GetNextPathPosition(); var gpos = _agent2D.GetNextPathPosition(); var dir = (gpos - _body2D.GlobalPosition).Normalized(); // _body2D.SetVelocity(dir * _speed * (float)delta); _body2D.GlobalPosition += dir * _speed * (float)delta; } }