Basic player & enemy movement.

This commit is contained in:
2026-01-31 01:54:47 +02:00
parent 50a64cc8aa
commit be0c819c8b
25 changed files with 612 additions and 1 deletions
+26
View File
@@ -0,0 +1,26 @@
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;
}
}
+1
View File
@@ -0,0 +1 @@
uid://cu37tswrk107q