Skip to content
RED SAGSkills
easyGame Developer interview question

How do you use vectors, dot product and cross product in game development?

What the interviewer wants to hear

  • Vectors represent positions, directions and velocities
  • Normalising gives a direction of length 1
  • Dot product: angle between vectors, front/behind, view cones, lighting
  • Cross product: perpendicular vector, left/right test, surface normals
  • Distance and magnitude for range checks

Model answer

Vectors are everywhere in games. A position is a point, a velocity is a direction with speed, and the difference between two positions gives the direction and distance from one object to another. Normalising a vector gives a pure direction of length 1. The dot product of two unit vectors gives the cosine of the angle between them, so I use it to check whether an enemy is in front of the player, to build a view cone, or for lighting, where light intensity depends on the angle to the surface normal. The cross product gives a vector perpendicular to two others. I use it to find surface normals, to build a coordinate frame for a camera, and to check whether a target is to the left or right of the player.

Can you answer it under time pressure?

Take a timed easy round and get scored on every answer.

Start mock interview

More easy Game Developer questions