1

Im trying to make an auto turret but when teleporting the entity in place and making it face another using the tp "facing" argument it faces the entity's feet, this is annoying because when the entity gets far enough away the arrows will undershoot seeing as the target is the feet

How do I make it face the head so it will be more accurate?

This is my code:

/execute as @e[tag=AS] at @s anchored eyes run tp @s ~ ~ ~ facing entity @e[tag=!ASUser,limit=1,sort=nearest,distance=0.1..,type=!minecraft:arrow,type=!minecraft:item,type=!minecraft:experience_orb]

1 Answer 1

1

Rotating an entity so that the looking direction goes from its feet to something else's feet (the normal case):

/execute as … at @s run tp @s ~ ~ ~ facing entity …

Rotationg an entity so that the looking direction goes from its feet to something else's eyes (usually looking up, which I assume you want here):

/execute as … at @s run tp @s ~ ~ ~ facing entity … eyes

Rotating an entity so that the looking direction goes from its eyes to something else's feet (usually looking down, the entity looks at the other entity's feet):

/execute as … at @s anchored eyes run tp @s ~ ~ ~ facing entity …

Rotating an entity so that the looking direction goes from its eyes to something else's eyes (which might be different from the first case because eye heights can differ):

/execute as … at @s anchored eyes run tp @s ~ ~ ~ facing entity … eyes

The teleport syntax with facing is a bit tricky, because autocomplete doesn't work and the instant validation keeps claiming that you're doing something wrong, pretty much all the way until you finish typing the command, when it turns out that it was right all along.
Here is the bug report about it: https://bugs.mojang.com/browse/MC-124053
The game's log also includes a warning about the conflicting syntax every single time the game is started, so Mojang probably knows about it.

1
  • Amazing! thank you, had no idea there was another choice at the end, I thought it stoped after selecting the entity!
    – guy
    Commented Apr 15, 2020 at 23:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.