Here’s a bunch of ways to inspire unique traps and puzzles for your setting, mostly from a D&D perspective.

Trap Creativity

Create Danger. Take something that already exists in a dungeon’s room and imagine how it could be made dangerous. Is there a big snake statue in a room? Perhaps looking into its eyes can petrify you or stepping on a hidden tile releases poison gas from its mouth. Keep in mind that empty rooms can be just as deadly. Imagine ways that the walls, floor, or ceiling could have a trap within it.

Random Object. Add a random thing to a room, perhaps using the Dungeon Furnishing tables in the D&D 5e DMG (pg 299-301). Then imagine how that could be used as a trap. Maybe a sextant on a table stabs those who try to peer through it. You could even use the random noise, odor, and atmosphere tables on those pages to create hints of a trap’s existence. A metallic smell could mean there are a lot of mechanisms in the walls implying a large section of the room may move. A mist-covered floor could be hiding an open pit.

Random Spell. Pick a random D&D 5e spell and think of how to use it for a trap, even if it’s usually a harmless spell. Say you pick magic mouth. What if the spell calls for help to lure creatures into a trap? What about create food and water? Maybe food continues to spawn filling a room with thick peanut butter, trapping victims inside? Magical traps leave a lot more room for creativity than physical mechanisms do. The same could apply to technology in a scifi setting that could perhaps mimic some magical effects.

Roll Randomly. I sometimes forget there’s a set of tables to create traps in the D&D 5e DMG (pg 297). They aren’t particularly creative, but can be a jumping-off point if you wish to push the creativity of the trigger or the trap itself, perhaps adding another layer to it in complexity.

Puzzle Creativity

Copy Existing Puzzles. Look at puzzles from the real world and figure out how to incorporate them into your setting, perhaps by abstracting them or changing the variables. Look in science or toy stores or else find puzzle-filled web sites. You can find that there are many logic and shape and word puzzles that already exist which can prove challenging for players. Remember, most puzzles don’t need to be complicated to fool a group of adventurers. After all, they still need to figure out a puzzle’s goal when the only things they have to go on are the GM’s descriptions and perhaps a hastily-drawn schematic with a riddle for an instruction sheet.

Random Object. Take something in a room and imagine how it could be used part of a puzzle. This works especially well for objects that have moving parts or states that can be toggled. A drawer could be closed or open, for instance. With a series of drawers, you could encourage the players to make sure certain ones are open and closed to unlock a door. Maybe the key is written somewhere in the form of symbols that correspond to the drawers’ handle shapes. Think creatively about where things can hide on objects with secret compartments and such.

Object Series. Take a series of objects and alter some key aspects of them to help create a puzzle. Let’s say for instance that you have a room with a series of humanoid statues. You could change the materials of the statues, have them painted different colors, give them different weapons, give each one a different face, or give each one a different pose. Once you change one of these aspects, you can start to create a puzzle that cares about each particular statue. Maybe they need to be rearranged, or the series needs to be completed, or maybe the statues inform the players what to do if they mimic them.

Relate Two Objects. Take two objects in a room and make them somehow interconnected. Maybe changing the state of one can affect the state of the other. Maybe they need to be used in tandem to solve the puzzle. For instance, you could have a table in an empty room with a locked door that has no handle or keyhole but four 2-inch holes near the corners of it. If you insert the table’s legs into the four holes in the door it will open.

Random Spell. Pick a random D&D 5e spell and think of how to use it as a variable of a puzzle, but try not to just use damaging spells as a trap on failure of the spell. For instance, a continuous scorching ray might project from a gargoyle’s mouth and it needs to be pointed at a red plate to open a door.