How can you teleport an entity relative to another entity?

How can you teleport an entity relative to another entity? - Orange and White Dr Pepper Can on Black Wooden Table

I have this command below in a command block, but it doesn't work.

execute @p ~ ~ ~ tp @e[type=ArmorStand] ~ ~-8 ~

It should teleport the armor stand 8 blocks below the player, but it doesn't. It teleports the armor stand relative to the armor stand. Do you have an answer for this?

Thanks in advance.



Best Answer

The current answers are all outdated. Now there's the /teleport (archive) command, which has none of the side effects of the current answers:

/teleport @e[type=armor_stand] ~ ~-8 ~

/teleport teleports relative to the executor instead of relative to the target, which makes it consistent which other commands.

In 1.13+ you can also write tp instead of teleport, because it behaves the same.




Pictures about "How can you teleport an entity relative to another entity?"

How can you teleport an entity relative to another entity? - A Man Standing with a Can of Paint
How can you teleport an entity relative to another entity? - A Person Putting Money in a Can
How can you teleport an entity relative to another entity? - Book On A White Wooden Table



How do you teleport entities to other entities?

Thanks to cheat console commands, Minecraft players can teleport just about any being in the game. To move mobs like animals, enemies, and villagers, the "/tp @e" or teleport entity command can be used to whisk them away to a designated location.

How do you use a command block to teleport an entity?

Type this command in when having the command block GUI open /teleport @p <x> <y> <z> . Then, activate the command block with redstone (including buttons, levers, and pressure plates), and they will be sent to their destination. The player can set up multiple different teleports.

Can you teleport to another dimension Minecraft?

To teleport, tap the Chat icon once again, bring up the text box and type /tp YourUsername X Y Z, with X representing the east/west coordinate, Y representing the vertical coordinate and Z representing the north/south coordinate.



Minecraft Command Blocks: Randomized Teleportation of Entities around an Entity or Location




More answers regarding how can you teleport an entity relative to another entity?

Answer 2

You would need to make a setblock/fill clock and then write these commands in order:

execute @e[type=Player] tp @e[type=ArmorStand] @p
tp @e[type=ArmorStand] ~ ~-8 ~

Then the Armor Stand will be teleported to you and then it will be teleported eight Blocks Down.

Answer 3

For version 1.9, you would have a repeating command block with the command /tp @e[type=ArmorStand] @p, and a chain command block set to conditional with the command /tp @p ~ ~-8 ~.

Answer 4

/execute as @e[type=armor_stand] run tp yourname @s

/execute as executes as the selected entity. For example, if you ran /execute as your friend ran kill @s, it'd kill your friend.

tp @s just teleports yourself to the entity it's being ran from.

Answer 5

Nevermind, I believe I found a fix.

As shown here, two separate teleports should be used - the first to teleport the armor stand to the object, and the second to teleport the armor stand relative to their new position.

So execute @p ~ ~ ~ tp @e[type=ArmorStand] ~ ~-8 ~ becomes

/tp @e[type=ArmorStand] @p
/tp @p ~ ~-8 ~

Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Erik Mclean, ANTONI SHKRABA, Towfiqu barbhuiya, Ylanite Koppens