I'm building a 2D infinite runner. In the game, character jumps from pillar to pillar and pillars are randomly generated. I have this working. But how to determine if the character failed to jump on to a pillar and has fallen into the gap between pillars? A pillar is ordinary rectangular in shape.
Add a rectangular region at the bottom of the level, lower than the minimum allowable height of a platform. If the player has intersected this region, they have fallen off a platform.
If your game only scrolls horizontally, you could check whether the vertical position of the character is below the lower edge of the stage.
If your game scrolls vertically as well (probably upward), you could check whether the player has fallen below the bottom edge of the view (i.e. the area of the stage that is onscreen, or in focus of the camera).
In general, the death condition is if the character fails to remain "in camera". By controlling the movement of your camera, you'll be able to tune your gameplay. For example, if in a vertical scrolling stage you only allow your camera to "rubberband" a little bit downward, while allowing full upward motion, you will penalize deep, offscreen falls.
Alternatively to checking the vertical coordinate, you could just check the vertical velocity. If the character is falling down faster than some threshold, conclude they're dead (even if there is some platform low enough to still reach, the impact would be fatal).
Of course, this only works if your game properly implements basic free-fall physics, i.e. the downwards velocity actually increases during the fall, as it does in reality (up until terminal velocity).
If you have height of pillars, you can find lowest existing, and compare it to vertical position of player. If he is below lowest pillar, there is no chance he can get back. You can limit this check only to pillars behind and in front of player.
Example: We have 3 pillars, with heights [10, 20, 40]. Player jumped is on pillar with height 40, he jumps forward to 20. He felt in gap between 40 and 20, he's now at height 15. That means he felt. For less strict check, wait till he is below 10.
Keep a count of how long a character has fallen. (i.e. how long they've been moving "down"). Once they've fallen more than a screenful of time, they by definition have fallen off the stage, yes?