A swarmkeeper ranger can choose to be moved by the swarm 5 feet horizontally in a direction of their choice. Does this create an attack of opportunity considering that it is happening immediately after they hit a creature with an attack?
The Players Handbook, under "Opportunity Attacks" states:
You also don't provoke an opportunity attack when you teleport or when someone or something moves you without using your movement, action, or reaction. For example, you don't provoke an opportunity attack if an explosion hurls you out of a foe's reach or if gravity causes you to fall past an enemy.
Then we have the Swarmkeeper ability which states:
Once on each of your turns, you can cause the swarm to assist you in one of the following ways, immediately after you hit a creature with an attack:
You are moved by the swarm 5 feet horizontally in a direction of your choice.
Put the two together and this doesn't generate an opportunity attack because "someone or something" (i.e. the swarm) moved the ranger and this movement didn't cost any of the ranger's movement, action or reaction.
A swarmkeeper ranger can choose to be moved by the swarm 5 feet horizontally in a direction of their choice. Does this create an attack of opportunity considering that it is happening immediately after they hit a creature with an attack?
No. You only provoke an attack of opportunity when you use your movement or reaction to move yourself.
Since the wording is "moved by the swarm," it does not provoke opportunity attacks.
Opportunity attacks are provoked only if you move under your own power.
The Players Handbook, under "Opportunity Attacks" states:
Then we have the Swarmkeeper ability which states:
Put the two together and this doesn't generate an opportunity attack because "someone or something" (i.e. the swarm) moved the ranger and this movement didn't cost any of the ranger's movement, action or reaction.