reckfellENGINE

Player input with Input Map

Define movement actions, read an input vector and separate gameplay input from menus.

On this page

Define actions

Open Project → Project Settings → Input Map. Add these exact, case-sensitive names without spaces:

ActionKey
move_leftA or Left Arrow
move_rightD or Right Arrow
move_upW or Up Arrow
move_downS or Down Arrow

An action can have several keyboard or gamepad bindings. The game reads the action name rather than a particular layout.

Move an object

Create a textured Sprite2D inside the window, for example at (320, 180). Attach MoveMarker.cs, build C# and run the current prefab with F6:

C#
using Reckfell;

public partial class MoveMarker : Entity2D
{
    [Export] public float Speed { get; set; } = 250.0f;
    public bool GameplayEnabled { get; set; } = true;

    public override void _PhysicsProcess(double delta)
    {
        if (!GameplayEnabled)
            return;

        Vector2 direction = Input.GetVector(
            "move_left", "move_right", "move_up", "move_down");
        Position += direction * Speed * (float)delta;
    }
}

At Speed = 250, the object travels 250 pixels per second along one axis. GetVector() limits vector length to one, preventing faster diagonal movement. For analog sticks it also applies a dead zone.

This example changes position directly and does not resolve collisions. For a character blocked by walls, use CharacterBody2D, Velocity and MoveAndSlide() in the 2D example. In 3D, use CharacterBody3D.

Holding and pressing once

Input.IsActionPressed() reads the held state. Input.IsActionJustPressed() reports the start of a press in the current frame or physics tick; reading it does not consume the press for other scripts. To react after UI processing, use _UnhandledInput() and InputEvent.IsActionPressed().

An open menu does not automatically block Input polling. Set GameplayEnabled = false from the menu controller or pause the gameplay branch. See event processing order.

If controls do not work

  • Give the game window focus.
  • Compare all four action names with the code; creating an action does not automatically bind a key.
  • Check script attachment, the build and GameplayEnabled.
  • Do not multiply CharacterBody2D.Velocity by delta before MoveAndSlide(): velocity uses pixels per second, and movement applies the time step itself.
Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.