How does collision detection work in a game engine, and what is the difference between a collider and a trigger?
What the interviewer wants to hear
- Colliders are simple shapes like boxes, spheres and capsules
- Broad phase finds possible pairs, narrow phase checks exact overlap
- Collider creates a physical response; trigger only reports overlap
- Layers and collision matrices filter what collides
- Fast objects may need continuous collision detection
Model answer
Game engines usually do not test collisions against the detailed mesh. Instead, objects have simple collider shapes such as boxes, spheres and capsules, or a simplified mesh. The physics engine first does a broad phase, using bounding boxes and spatial structures to find pairs that might touch, then a narrow phase that checks exact overlap and contact points. A normal collider makes objects physically collide, so they bounce or stop. A trigger only reports that something entered or left its area, with no physical response, which is perfect for pickups, checkpoints and damage zones. I use layers and the collision matrix so, for example, bullets do not hit other bullets. For very fast objects like bullets I enable continuous collision detection or use raycasts so they do not pass through walls.
Can you answer it under time pressure?
Take a timed easy round and get scored on every answer.
More easy Game Developer questions
- What is a game loop, and why is delta time important?
- In Unity, what is the difference between Awake, Start, Update, FixedUpdate and LateUpdate?
- How do you use vectors, dot product and cross product in game development?
- Tell me about a game or game feature you built. What was the hardest problem and how did you solve it?
- Why do game engines like Unity and Unreal favour components over deep inheritance trees for game objects?
- How would you set up version control for a small game team with programmers and artists?
- What do you do as a programmer to make a game "feel" good to play?
- What are coroutines in Unity, and when would you use them instead of Update or async/await?
- How do you use prefabs, nested prefabs and prefab variants to keep a Unity project organised?