Minecraft wiki entry for Flying_machines, associated text: An engine can also move diagonally by moving alternately along 2 axes. The Diagonal Engine shown is best built out from level 3 (the upper slime--and-piston layer). It moves along its slime-block diagonal, but is guided by immovable (e.g., obsidian) barriers on level 3, so it can follow a straight or curved "rail", in whichever direction(s) it can move until it reaches a corner to block it. It is started by activating either of the observers on top (placing a block, flint-and-steel), and will move away from that corner (that is, it is also a two-way flyer).
Credits: design from "samnrad" ("smart diagonal flying machine and curved flying machines" YouTube