Teleport a player to face an entity?

If I have an entity, is it possible to teleport that player to face the entity without teleporting the player to the entity (Just changing his rotation)? How could I accomplish this?
Best Answer
The new syntax for /teleport
in 1.13 added a "facing entity" option.
/execute as @p positioned as @s run teleport @s ~ ~ ~ facing entity ENTITY_TO_FACE
Pictures about "Teleport a player to face an entity?"



How do you teleport facing an entity in Minecraft?
/tp is no longer different from /teleport now, and became an alias of /teleport . Added facing to /teleport , which causes the target entity to face an entity or a location. /teleport has been simplified a bit and players can now teleport to entities in other dimensions.How do you teleport entity to a player?
Players who want to move mobs to their character's position or move their character to the mob's position can use the following commands:Update to the /tp facing command minecraft 1.13
More answers regarding teleport a player to face an entity?
Answer 2
Here's an alternate solution to the other answer. It should work more accurately without thousands of command blocks, although it relies a lot more on trickery rather than a kind of brute-force method.
When you summon the Target mob that you want to face towards, you need to give it a specific UUID so that the UUID isn't chosen at random. I'll use an ArmorStand
for this example:
/summon ArmorStand ~ ~1 ~ {CustomName:"Target",UUID:1-2-3-4-5}
If you're wanting to face towards a naturally spawned mob (where the UUID will be random), you'll need to summon another entity on top of it with a specific UUID as shown above.
Near to this Target, summon some kind of mob that can be aggressive, but also give it slowness and anti-jump boost. I'm using a Witch for this, although they throw potions which you may need to /kill
. You can also make this Aggressor invisible if you don't want players to notice it.
/execute @e[name=Target] ~1.5 ~ ~ /summon Witch ~ ~ ~ {AbsorptionAmount:350000000000000000000000000000000000000.0f, CustomName:Aggressor,CustomNameVisible:1,Attributes:[{Name:"generic.knockbackResistance",Base:1f},{Name:"generic.movementSpeed",Base:0f}],ActiveEffects:[{Id:8,Amplifier:-127,Duration:2147483647}]}
(The huge absorption amount is to make this Aggressor invincible, but still able to take damage)
Now you'll want to make the Aggressor angry at the Target. This is the reason we needed the Target to have a UUID that we know, we're going to summon a snowball that pretends it has been thrown by the Target above the Aggressor:
/execute @e[name=Aggressor] ~ ~ ~ /summon Snowball ~ ~2.1 ~ {ownerName:"1-2-3-4-5"}
The snowball falls onto the Aggressor, and it thinks the Target threw it (ArmorStands don't even have arms, but mobs are dumb) and starts tracking the Target.
At this point you should have whatever mob you're using looking very angry at an ArmorStand.
Now that the setup is done, it's fairly easy to use, even repeatedly.
Teleport the Aggressor to the player:
/tp @e[name=Aggressor] @p
Then wait a moment as the Agressor reorientates to face the target, and then teleport the player to the Aggressor:
/tp @p @e[name=Aggressor]
Answer 3
You can do it with armor stands.
When a player teleports to an armor stand, they take the rotation of the armor stand. Here is what you do:
- Summon an armor stand 1 block south of the entity, facing north.
- Teleport the player to that armor stand.
- Kill the armor stand.
It will be useful to name the armor stand so you can find it later without interfering with other armor stands.
EDIT: How to do it without moving the player
You'll need a lot of command blocks, one for each little arc of the circle. The more you have, the more accurate it will be.
Here are the steps:
- Create an armor stand exactly where the player is.
- Based on where the entity is relative to the player, rotate the armor stand to face the entity. This is the part that requires a lot of command blocks. For example, if the player is 1 block south and 1 block east of the entity, the armor stand should rotate to 135ยบ. You then divide the area surrounding the entity into a grid, then make a command block for each square. The command block makes the armor stands face the right way based on which grid square it is (you calculate the correct rotations beforehand). The grid squares can be larger than 1 block by 1 block.
- Teleport the player to the armor stand. It's at the same place as the player, but rotating the right way, so the player will rotate.
You need to use the armor stands because you can't edit a player's entity data.
I think SethBling did a video with this type of thing once. I can't find it right now, but I think it was about a nether portal that showed you the nether on the other side. There was another video about endermen that always face you that might help.
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: cottonbro, cottonbro, RF._.studio, Olha Dobosh