Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Game Development with Godot & GDScript Module 6

Game math and 2D physics interview questions

Interview questions on game math and 2D physics: short warm-ups, then what each harder question tests, the first step of a good answer and its follow-ups.

18 questions: 6 warm-ups and 12 with model answers · Levels: Fresher to senior

Warm-up questions

Short questions with short answers, each answered in full.

  1. Fresher

    What does the dot product of a guard's facing and the direction to the player tell you?

    Answered in the lesson Vector math for games

  2. Fresher

    What is the difference between position and global_position on a Node2D?

    Answered in the lesson Transforms and coordinate spaces

  3. Fresher

    What is the difference between a collision layer and a collision mask?

    Answered in the lesson Physics bodies, layers and masks

  4. Fresher

    Why is velocity not multiplied by delta before move_and_slide()?

    Answered in the lesson Platformer and top-down character controllers

  5. Fresher

    What is the difference between an impulse and a force on a RigidBody2D?

    Answered in the lesson Rigid bodies, raycasts and physics queries

  6. Fresher

    What is the difference between _process() and _physics_process()?

    Answered in the lesson Physics ticks, interpolation and jitter

Questions with model answers

What each question tests, the first step of a good answer and the follow-ups to expect.

  1. Fresher to mid

    Playtesters say stealth guards notice them from far off to the side, almost behind, although guards should see only 90 degrees ahead. The check is facing.dot(player.global_position - global_position) > 0.707. What is wrong, how do you fix it, and how do you keep the check cheap for 200 guards?

    What it tests
    Knowing that the dot product is the cosine only for unit vectors, comparing with the cosine of the half-angle, and keeping a per-tick check cheap with squared distances and early exits.
    First step
    Write the dot product out: it is the offset's length times the facing's length times the cosine of the angle. With a raw offset the left side grows with the distance, so a player 180 px away and 56 degrees off gives 100, far above 0.707. Normalize the offset, or use direction_to(), before comparing with cos(45°).
    Follow-ups

    From the lesson Vector math for games

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.

    Opening the model answers with your pass…

    Model answers open with any MySmartCoPilot pass.

    • Pro pass · 1 week₹79$2.99
    • 30 days₹179$5.99
    • 1 year₹1,699$45

    One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

    It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 4 minutes
  2. Fresher to mid

    A camera follows the player with position = position.lerp(target, 0.1) in _process(). On 144 Hz monitors players call it twitchy, and on a slow laptop it lags behind. Explain why, fix it so that it feels the same everywhere, and say how you would test the fix.

    What it tests
    Seeing that a fixed lerp weight per frame compounds with the frame rate, deriving a frame-rate independent weight from exp(-k * delta), and testing motion at fixed frame rates.
    First step
    Count the frames. Each one takes 0.1 of the remaining gap, so 144 frames a second take far more shares in the same time than 30: in half a second the camera closes 99.95 % of a jump at 144 and 79.41 % at 30. The share must depend on how long the frame lasted.
    Follow-ups

    From the lesson Vector math for games

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 4 minutes
  3. Fresher to mid

    A turret mounted on a ship aims perfectly while the ship faces right and misses more the more the ship turns. It sets rotation = (target.global_position - global_position).angle(). Explain the miss with numbers, give two fixes, and say how the fix changes when the turret sits on a mount that also turns.

    What it tests
    Knowing that rotation is relative to the parent, converting with to_local() or look_at(), and composing several parents' transforms.
    First step
    Name the spaces. The angle is measured in the world, but rotation is relative to the ship, so the ship's own turn is added on top: a ship turned 30 degrees makes the muzzle point 30 degrees off. The angle has to be measured in the parent's space, or the parent's rotation taken off.
    Follow-ups

    From the lesson Transforms and coordinate spaces

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  4. Mid to senior

    Markers on the HUD that should sit over enemies are placed at each enemy's global_position. They look right in the first room, drift away as the camera follows the player, and jump when the player turns on a UI scale of 200 %. Explain each symptom and design the conversion.

    What it tests
    Following a point through the canvas transform of a Camera2D and a CanvasLayer's own transform, and keeping world-sized and screen-sized things in the right space.
    First step
    List the transforms between the enemy and the HUD. The enemy's global position is in the world; the camera's canvas transform takes it to the screen; the HUD layer's transform, with its scale, takes HUD points to the screen. The marker needs the screen point taken back through the layer.
    Follow-ups

    From the lesson Transforms and coordinate spaces

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  5. Fresher to mid

    Design the collision layers and masks of a co-op shooter: two players, enemies, player shots, enemy shots, pickups and walls, with friendly fire off. Say which node each object is, what each mask holds, and how you would test that exactly the right pairs interact.

    What it tests
    Turning an interaction table into layers and masks, knowing that detection runs from the mask's side, choosing bodies and areas, and testing the whole table automatically.
    First step
    Write the table from the detector's side: one row per kind, listing what it must detect. Give each kind its own layer, then each mask is the sum of the bits in its row. Shots are areas, so they only report; players and enemies are character bodies that look at walls.
    Follow-ups

    From the lesson Physics bodies, layers and masks

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  6. Fresher to mid

    A moving platform is a StaticBody2D that an AnimationPlayer moves up and down. Crates on it rise with it but never fly off when it stops sharply, and players report that jumps from it feel wrong. Explain what happens and what you would change.

    What it tests
    Knowing that a moved StaticBody2D teleports without giving bodies its speed, that an AnimatableBody2D pushes with its own velocity, and how a character inherits a platform's speed.
    First step
    Measure the crate's speed while it rides. A StaticBody2D moved by code is teleported; the crate is pushed out of it each tick but keeps a speed of 0, so it has nothing to fly off with. An AnimatableBody2D moves through the physics step and gives what it pushes its own speed.
    Follow-ups

    From the lesson Physics bodies, layers and masks

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  7. Fresher to mid

    A designer specifies a jump: 96 px high, 0.4 s to the top, forgiving of presses a little late or early, and lower when the button is let go early. Write down the controller's numbers and logic, explain why a naive version jumps 100 px, and say how you would prove the spec holds.

    What it tests
    Deriving gravity and jump speed from height and time, the error of stepping a jump tick by tick, coyote time and buffers in seconds, and headless tests that replay input on exact ticks.
    First step
    From constant acceleration: g = 2h / t² = 1,200 px/s² and v = 2h / t = 480 px a second. Then check the stepping: moving with the speed at the end of each tick runs ahead of the curve, and the first tick at the full speed adds a whole 8 px.
    Follow-ups

    From the lesson Platformer and top-down character controllers

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 4 minutes
  8. Fresher to mid

    On a level with long downhill slopes, the hero visibly bounces as it runs down, its jumps are sometimes ignored on the way down, and it runs faster downhill than on the flat. Uphill, a 50-degree ramp stops it dead. Explain each symptom and the settings you would change.

    What it tests
    Knowing floor_snap_length, floor_max_angle and floor_constant_speed, and how leaving the ground for a tick breaks is_on_floor() and with it jumping.
    First step
    Count the ticks the hero spends in the air on the slope. Each move along the velocity ends above the falling ground, gravity brings it back a tick later, and on every airborne tick is_on_floor() is false, so a jump pressed then is refused. Snapping keeps it on the ground.
    Follow-ups

    From the lesson Platformer and top-down character controllers

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  9. Fresher to mid

    Enemies in a stealth game sometimes see the player through walls, and sometimes fail to see a player standing in the open in front of them, half hidden by a crate. Each enemy casts one ray to the player's centre with the default query parameters. Diagnose both bugs and design a better sight check.

    What it tests
    Masks and exclusions in ray queries, reading an empty result versus a hit, rays from a point versus the body's size, and the order and cost of the checks.
    First step
    Look at what the default ray can hit: every layer, so the player's own body or a crate counts as a blocker. Then look at where it starts: an enemy pressed against a wall has its eye inside the wall's shape, and a ray that starts inside a shape skips it. Give the ray only the blockers' layers, and start it outside walls.
    Follow-ups

    From the lesson Rigid bodies, raycasts and physics queries

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  10. Mid to senior

    A physics puzzle game stores replays as the player's inputs and re-simulates them. Replays look right on the developer's machine, but players report that boxes end up elsewhere, especially after a patch that raised the physics tick rate. Explain what is happening and design replays and tests that hold up.

    What it tests
    What a physics simulation's result depends on (build, tick rate, order of events, platform), and recording results or pinning every input of the simulation instead.
    First step
    List what the result depends on besides the inputs: the tick rate, the build and engine version, the order in which bodies were added and the machine's floating-point behaviour. Raising the tick rate alone changes every result, so every old replay re-simulated under the new rate has diverged.
    Follow-ups

    From the lesson Rigid bodies, raycasts and physics queries

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  11. Mid to senior

    A 2D platformer looks smooth on 60 Hz monitors, but players with 144 Hz monitors say the hero and the scrolling level shake. Physics runs at 60 ticks a second and interpolation is off. Explain the shake with numbers, fix it, and say what else in the code the fix makes you change.

    What it tests
    Ticks against frames, physics interpolation and its rules (movement in ticks, resets after teleports, cameras), and the cost in input delay.
    First step
    Count ticks per frame. At 144 frames and 60 ticks a second, two or three frames share each tick, so a hero at 300 units a second is drawn moving 0, 0 and then 5 units, an uneven step on a 60 Hz rhythm. On 60 Hz screens every frame has one tick, which is why it looks fine there.
    Follow-ups

    From the lesson Physics ticks, interpolation and jitter

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  12. Mid to senior

    A game's physics tests run headless on a build server. They take several minutes, and a few fail now and then with positions a little off, then pass on a rerun. Explain both problems and design a test setup that is fast and gives the same answer every time.

    What it tests
    Real-time synchronization against --fixed-fps, what makes a physics run repeat (frame time, jitter fix, tick rate, input timing, scene order), and tolerances.
    First step
    Without options, a headless run keeps physics in step with the wall clock, so 120 ticks wait two seconds whatever the machine. --fixed-fps gives every frame a fixed game time and drops that wait. The random failures point to anything still taken from the clock or the frame timing.
    Follow-ups

    From the lesson Physics ticks, interpolation and jitter

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes

All Game Development with Godot & GDScript interview questions · The Game Development with Godot & GDScript track

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.