I feel like this question has been asked before, but I couldn't find it.
I know that if you are engaged in combat with someone (or at least in melee range of someone's weapon, 5 feet normally or 10 with polearms) and you move away willingly on your turn, your opponent can make an opportunity attack. I am also aware that if you are engaged in melee combat with a target, you can sidestep around them without them being able to make an opportunity attack if you stay within 5 feet (or 10 for polearms).
What I want to know is, on your turn if you start OUT of the melee range, then enter the melee range (whether by passing or attacking), and then leave the melee range, can your opponent then make an opportunity attack? More specifically for movement purposes.
So if a monk runs past a bandit when he previously wasn't in Melee range before, can the bandit make the attack? Or does he have to start his turn in Melee range and then move?