I am wondering how to spawn an entity behind another one but it does it based on where the entity is facing
11 Answer
Use the new caret notation. Tildes (~ ~ ~) use global positioning and carets (^ ^ ^) use local positioning. So the command looks like this:
/execute as <someEntity> at @s run summon <entity> ^ ^ ^-1The first caret is for left and right, the second one is for up and down, and the third one is for forward and backward. So ^ ^ ^-1 means 1 block behind the entity (regardless of its rotation).