The engine provides keyboard and mouse input through GLFW, exposed to C# via NativeBridge.
Poll individual keys each frame:
if (NativeBridge.IsKeyPressed(NativeBridge.KEY_W))
{
// W is held down
}
Available Key Constants
For other keys, pass the GLFW key code integer directly.
Cursor Position
double mx, my;
NativeBridge.GetCursorPos(out mx, out my);
Returns the cursor position in window coordinates.
Cursor Lock
NativeBridge.SetCursorLocked(true); // capture + hide cursor
NativeBridge.SetCursorLocked(false); // release cursor
bool locked = NativeBridge.IsCursorLocked();
When locked, the cursor is hidden and raw mouse input is enabled for camera look. The CameraFollowSystem uses ESC to toggle this automatically.
Poll individual mouse buttons each frame:
if (NativeBridge.IsMouseButtonPressed(NativeBridge.GLFW_MOUSE_BUTTON_LEFT))
{
// Left mouse button is held down
}
Read accumulated scroll delta and reset each frame:
float scrollX, scrollY;
NativeBridge.GetScrollOffset(out scrollX, out scrollY);
NativeBridge.ResetScrollOffset();
The CameraFollowSystem uses scroll wheel for third-person camera zoom automatically.
Note
When the free camera is active (press 0), InputMovementSystem is disabled — WASD controls only the free camera. Press 1 to return to normal controls.
The InputMovementSystem uses input for a physics-based player controller:
public static void InputMovementSystem(World world)
{
var entities = world.Query(typeof(Movable), typeof(Transform), typeof(Rigidbody));
foreach (int e in entities)
{
float inputX = 0f;
float inputZ = 0f;
if (NativeBridge.IsKeyPressed(NativeBridge.KEY_A)) inputX -= 1f;
if (NativeBridge.IsKeyPressed(NativeBridge.KEY_D)) inputX += 1f;
if (NativeBridge.IsKeyPressed(NativeBridge.KEY_W)) inputZ += 1f;
if (NativeBridge.IsKeyPressed(NativeBridge.KEY_S)) inputZ -= 1f;
// Convert input to camera-relative direction and set body velocity...
bool jumpPressed = NativeBridge.IsKeyPressed(NativeBridge.KEY_SPACE);
// Edge-detect space + grounded check, then apply jump vertical velocity...
}
}
WASD movement is camera-relative when the entity has a Camera component. The player mesh rotates to face the move direction.