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
+31
View File
@@ -0,0 +1,31 @@
using Godot;
using System;
public partial class PlayerMovement : Node
{
[Export] private CharacterBody2D _body2D;
[Export] private float _speed;
private Vector2 _direction = new ();
public override void _Process(double delta)
{
ReadInput();
}
public override void _PhysicsProcess(double delta)
{
float dt = (float)delta;
_body2D.SetVelocity(_direction * _speed * dt);
_body2D.MoveAndSlide();
}
private void ReadInput()
{
_direction.X = Input.GetAxis("move_left", "move_right");
_direction.Y = Input.GetAxis("move_up", "move_down");
_direction = _direction.Normalized();
}
}