Skip to content

Lesson 5 of 9 · 25m

Input, Camera, and Game Feel for Programmers

Use the Input System correctly, separate commands from simulation, and tune motion, camera, and feedback until controls feel intentional.

Game feel is not particle glitter sprinkled over bad controls. It is the chain from input sampling to simulation to presentation. When players say a game is floaty, unresponsive, or jittery, they are often describing timing bugs in that chain. Programmers own most of it.

Input is a stream of intent

Use the Input System package and define actions rather than polling key codes everywhere:

GameplayActions
├── Move        Vector2   WASD / left stick / d-pad
├── Jump        Button    Space / gamepad south
├── Fire        Button    Mouse left / right trigger
└── Pause       Button    Escape / start

Actions decouple intent from devices. Jump should not care whether it came from a keyboard, gamepad, or remapped accessibility control.

Sample in Update, simulate in FixedUpdate

The same lifecycle rule from earlier becomes a control-feel rule:

private Vector2 moveInput;
private bool jumpQueued;
private float jumpQueuedAt;

private void Update()
{
    moveInput = moveAction.ReadValue<Vector2>();
    if (jumpAction.WasPressedThisFrame())
    {
        jumpQueued = true;
        jumpQueuedAt = Time.time;
    }
}

Then consume the queue in fixed simulation. A short input buffer — around 0.1 to 0.15 seconds for many platformers — hides frame-boundary misery without feeling automatic.

Coyote time is honest generosity

Players often press jump just after leaving a ledge. Strict collision truth says they are airborne; human truth says the input should count. Implement coyote time explicitly:

if (isGrounded)
    lastGroundedAt = Time.time;

bool canJump = Time.time - lastGroundedAt <= coyoteSeconds;

This is not cheating. It is aligning the simulation with perception.

Cameras belong in LateUpdate or a camera system

If the camera follows in Update before the target finishes moving, it renders one-frame-old positions and creates jitter. A simple follow camera belongs after movement:

private void LateUpdate()
{
    var desired = target.position + offset;
    transform.position = Vector3.SmoothDamp(
        transform.position, desired, ref velocity, smoothTime);
}

For serious work, Cinemachine solves framing, damping, blending, confiners, and impulse noise better than most hand-rolled cameras.

Field notes

  • Mouse input is already frame-based; multiplying it by Time.deltaTime often makes sensitivity framerate dependent in the wrong way.
  • Record input while debugging. A reproducible jump failure is worth more than ten anecdotes.

Was this lesson helpful?

Sign in to rate