Workshop › Wolfenstein-style 3D Maze › Step 12 of 18
Look at a flat wall straight ahead: it bulges, taller in the middle. The side rays are longer, because they go slanted. A real eye (or camera) measures distance straight ahead, so we multiply by the cosine of the ray's angle from the middle.
```js
// The distance straight ahead, not along the ray: otherwise flat walls bulge (the fish-eye effect).
const dist = hit.dist * Math.cos(angle - player.angle)
```angle - player.angle is how far the ray turns from the middle of the view.Replace the dist line with the corrected one, and write the comment above it.
Skills: Velocity and gravity
← The 3D view Light and shade →