You can make an opportunity attack when a hostile creature that you can see moves out of your reach.
This question indicates that an Opportunity Attack is made when a creature moves behind Total Cover while within reach of an enemy:
The rules also say, SRD, page 76 - Opportunity Attack:
The attack occurs right before the creature leaves your reach.
A target with three-quarters cover has a +5 bonus to AC and Dexterity saving throws. A target has three-quarters cover if about three-quarters of it is covered by an obstacle.
If the Target is leaving the Creature's Reach by moving behind a wall, and the Opportunity Attack is taken just before this occurs, would the Creature receive the benefits of three-fourths Cover since much of their body is behind the obstacle at the point the Opportunity Attack is made?
Another situation this question is relevant to is burrowing creatures & ethereal creatures.