We show that well-known invariants like Lusternik–Schnirelmann category and topological complexity are particular cases of a more general notion, that we call homotopic distance between two maps. As a consequence, several properties of those invariants can be proved in a unified way and new results arise.