I've been trying to make an armor stand teleport in front of me by like two blocks no matter where I look, but I couldn't get it to work. Can anybody help me out please? Also I am playing on Minecraft Java Edition, and the version is 1.20.4
You can use the
^ symbol to teleport the armor stand relative to the player's body.
This command teleports the armor stand 2 blocks in the direction the player is looking:
execute at @p run tp @e[tag=tag] ^ ^ ^2
I added a second block after to set the y position of the armor stand to the same as the players:
execute as @p run data modify entity @e[tag=tag,limit=1] Pos set from entity @s Pos
I have an armor stand with the tag:
tag, and I checked for the closest player. You can use any method to specify the player.
This will teleport the armor stand up to 2 blocks away, as it is 2 blocks away from the player's head in a straight line.
If you want something different edit your question or add a comment on my answer.