This commit is contained in:
2026-01-31 23:24:13 +02:00
parent be0c819c8b
commit 12c1360ae7
58 changed files with 1902 additions and 238 deletions
+9 -15
View File
@@ -3,24 +3,18 @@ using System;
public partial class EnemyMovement : Node
{
[Export] private NavigationAgent2D _agent2D;
[Export] private CharacterBody2D _body2D;
[Export] private PathFollow2D _pathFollow2D;
[Export] private float _speed;
private double _time = 0;
public override void _PhysicsProcess(double delta)
public override void _EnterTree()
{
_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;
_pathFollow2D.ProgressRatio = 0;
}
public override void _Process(double delta)
{
_pathFollow2D.ProgressRatio += (float)delta * (_speed / 1000f);
}
}