save
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user