# All Game Engineer Interview Questions I’ve ever been asked

All the interview questions I have been asked since 2012.

I keep updating this list and adding/ modifying answers on a regular basis.

# Behavioural

- What games do you like to play?
- Did you play our game? What did you think?
- Why did you join the game industry?
- Why do you want to leave your current position?
- Where do you see yourself in five years? What are the next steps in your career?

# Mathematics

**Dot Product (Definition and Uses)**

**Cross Produce (Definition and Uses)**

## Calculate the Reflection when a Vector hits a Surface

Let’s say a vector **d** hits a surface with a normal **n**. The reflected vector is **r**. The reflection vector can be calculated by:

**r = d-2(d.n)n**

Where **d.n** is a dot product.

## Why use Quaternions over Eluer rotations?

- Using Quaternion rotations can prevent the Gimbal lock problem.
- Spherical Linear Interpolation or Slerp is much easier when using Quaternions.
- Four floating points represent quaternation rotations, while Euler rotations are represented by three, a very slight increase in storage.

## Check if a Point is inside a Rectangle

Where `(x1, y1)`

is the top right of the rectangle and `(x2, y2)`

is the bottom right of the rectangle. And `(x, y)`

is the point we want to check,

`x > x1 AND x < x2 AND y > y1 AND y < y2`

If the above is true, the point lies inside the rectangle.

## Check if two Rectangles Collide

(With X1 being left coord, X2 being right coord, **increasing from left to right** and Y1 being Top coord, and Y2 being Bottom coord, **increasing from bottom to top** — if this is not how your coordinate system [e.g. most computers have the Y direction reversed], **swap the comparisons below**) …

`if (RectA.X1 < RectB.X2 && RectA.X2 > RectB.X1 &&`

RectA.Y1 > RectB.Y2 && RectA.Y2 < RectB.Y1)

Reference: https://stackoverflow.com/questions/306316/determine-if-two-rectangles-overlap-each-other

## Check if two Circles/ Spheres collide

Where the distance between two circles can be computed by taking the Euclidean Distance of their centre positions, the following equation can compute if they overlap.

`if (Distance(CircleCenter1, CircleCenter2) <= CircleRadius1 + CircleRadius2)`

## How can you speed up distance comparisons between multiple objects in a 2D/3D space?

The distance can be computed using Euclidean Distance which has the formula: √((x1 — x2)² + (y1 — y2)²)

The square root operation is computationally expensive. To save CPU time we can skip the square root and compare the squared distances instead.

## Write a function that returns if a position is in the Field of View of the player.

## Implement a function that moves an entity smoothly from one point to another.

One way to do it would be using linear interpolation.

## Simulate a projectile motion trajectory

# General Programming

**How many numbers can a ****unsigned byte**

** represent?**

**unsigned byte**

It can represent 2⁸ numbers or numbers in the range of [0, 255].

**What is polymorphism?**

## What integer numbers are considered “true” when doing a logical operation in C++?

All integer numbers except for zero are considered true. Zero is considered false.

## What is the difference between passing by value, passing by pointer and passing by reference?

**Passing by Value: **Passing by value allocates memory and copies the values. Any changes made to the passed variables will not affect the original copy.

**Passing by Reference:** A reference to the initially allocated memory is passed. This saves memory and is also useful when we want to change declared variables or structures directly.

**Passing by Pointer:** A pointer to the allocated memory is passed. The memory reference can be accessed using the pointer.

## How does a compiler work?

# Javascript General Programming

I’ve worked as an HTML5 game engineer in some of my roles. In those cases, the interviewers assume that you have a basic understanding of how Javascript works.

## Is Javascript multithreaded?

No, it runs the application on a single thread. WebAssembly is also not multi-threaded.

## What is the difference between == and ===?

Double equal sign (==) performs a loose equality check. It doesn’t account for the data type.

Triple equal sign (===) performs a strict equality comparison. It also checks the data types of both values.

## How do you implement inheritance and polymorphism in Javascript?

# C++ General Programming

## Explain the need for a Virtual Destructor.

# Game Programming

## What is a Z-buffer/ Depth-buffer?

## What is a frustum?

A frustum is a shape with six sides. Two of these sides are perpendicular to the camera’s “eye”, called the near and far planes, respectively. Everything that’s in the frustum is rasterized and displayed on the screen.

## What is frustum culling?

Frustum culling is an optimization step in which we ignore and don’t render all objects that don’t exist inside the camera frustum.

## What is a vertex shader?

## What is a fragment shader?

## Implement the A* Pathfinding Algorithm

`// This provides a starting point. An A* algorithm is similar to BFS but it`

// also uses a heuristic

private void AStar() {

var queue = new Queue<Point>();

var startPoint = new Point(...);

var endPoint = new Point(...);

queue.Enqeue(startPoint);

while (queue.Any()) {

var p = queue.Deqeue();

if (p == endPoint) break;

for (all neighbours) {

var closestPoint = Math.Min(ComputeHeuristic(endPoint, neighbourPoint));

queue.Enqueue(closestPoint)

}

}

}

private float ComputeHeuristic(p, p2) {

return Math.Sqrt((p.x - p2.x)^2 + (p.y - p2.y)^2)

}

class Point {int x, int y};

## How does a LookAt function work?

# Algorithmic

## Write a program for an NxN Tic Tac Toe game.

Follow-up: Find if a player won in O(n) time.

Follow-up: Find if a player won in O(1) time.

## Program a target-seeking missle. The missile should face and follow the target as it moves around in 2D/ 3D space.

## Write a program to implement a point cloud system.

# Game Engine

## Describe the <insert engine her> order of execution of event functions, aka call stack.

Unity Engine: https://docs.unity3d.com/Manual/ExecutionOrder.html

Godot Engine: https://raheelyawar.medium.com/godot-script-lifecycle-52607bf320b9

# Unity

## C# Events vs. Unity Events

- Functionally they are the same.
- Unity events show up in the Unity Editor. If you’re making plugins or using drag and drop in the Editor, you’ll need to use UnityEvent.
- C# events are faster and use less memory.

## Is MonoBehaviour single or multi-threaded?

It is single-threaded. Coroutines also live on the main thread.

## Can you use multi-threading in Unity and what should you look out for while using it?

Yes, you can use async functions but you can’t use Unity library functions since they live on the main thread. You also would need to use the “System. Random” and similar library functions while using multi-threading.