Gilgamesh was the legendary king of Uruk, the ancient Mesopotamian city-state. Apparently, he was a historical figure who become the subject of legendary embellishment.
Since these were warrior cultures, it's probably the case that he was a warrior king. But in Mesopotamian mythology and royal propaganda, he become a demigod.
It's quite possible that's the kind of figure which Gen 6:1-4 is alluding to. It demythologizes what ANE culture mythologizes. Cuts him down to size. A mere mortal who goes the way of all "flesh" (v3).
And his legendary associations with a catastrophic flood would be a natural lead in to the account of the deluge in Gen 6-9. A historical figure, a historical flood. But in both instances, Genesis provides a corrective to what became garbled in heathen myth political or national legend.