4

I try to make a tagged Armor Stand look at the same place as the player, but I can't find a way to do it.

For example, if the player looks in the direction of the (x, y, y) block, the Armor Stand should look at the (x, y, z) block.

For now I wrote the following command, but it only rotates the Armor Stand in the same direction as the player, it doesn't make it look at the same place:

/execute as @e[tag=my_armor_stand] at @s rotated as @p run teleport @s ~ ~ ~ ~ ~

If this should take more than one command, it is also okay.

  • 1
    This is a duplicate of gaming.stackexchange.com/q/362586/171580. I would close it as such, but for some reason that's not possible while a bounty is on it. Why did you put a bounty on it? A simple Google search could have solved your issue AND saved yourself 100 points. – Fabian Röling Mar 25 at 21:00
  • @FabianRöling I don't think it is, because they're trying to replicate the direction a player is looking with an armour stand, whereas the other question is determining what block a player is looking at. – Corsaka Mar 27 at 12:49
  • @Corsaka Nope, that's exactly not what they want. The example command included in the question would do what you described, but they want the armour stand to instead look at the same block. – Fabian Röling Mar 27 at 15:06
2
+100
  1. Summon an Armor Stand with a specific tag, Invulnerable, and NoGravity.
    • summon minecraft:armor_stand ~ ~ ~ {Invulerable:1b,NoGravity:1b,Tags:["tag1"]}
  2. Every tick, teleport the Armor Stand to the relative position of the player
    • execute as @p at @s anchored eyes run tp @e[tag=tag1] ^ ^ ^2
  3. Every tick, teleport your own Armor Stand to face the new one
    • execute as @e[tag=tag2] at @s run tp @s ~ ~ ~ facing @e[tag=tag1,limit=1]
  4. Once you're done, kill the Armor Stand.
    • kill @e[tag=tag1]

Make sure to replace tag1 and tag2 with your actual tag names.

Edit: For looking at the block, you want to send out a different armor stand tag3 from the player and when that hits a block, teleport your tag2 armor stand to facing that one's location. Then repeat the process, sending out tag3 and teleportinng tag2 to face it until you're done. This is called raycasting

|improve this answer|||||
  • That's pretty complicated. How I understand the question, you just need to raycast until you hit the block and then rotate the armour stand once. If you use functions, you don't even need any dummy entities. – Fabian Röling Mar 29 at 14:43
  • Oh yeah you're right. – Sam Hill Mar 29 at 15:12

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