Arqade Asked on October 1, 2021
I want to rotate an armor stand wherever I am located. And I can do that through this command:
execute as @e[type=armor_stand] at @s run tp @s ~ ~ ~ facing entity @p
But I want it to face my XZ coordinates only. I don’t want its line of sight (the blue line in hitboxes) pointing directly at me when I’m flying. Any idea how?
Method #1: Correction. First teleport according to your command, then in the same tick change the rotation back to horizontal with this command:
/data modify entity @e[type=armor_stand,limit=1] Rotation[1] set value 0f
This might have the side effect that the armour stand is occasionally visible looking up or down for one frame, but it did not ever happen when I tried it. It might be different on a laggy server.
Method #2: Dummy entity. Have a dummy entity that is always at the player's X and Z coordinate, but at the armour stand's Y coordinate and let the armour stand look at that instead.
To be absolutely sure that you always target the correct player, you need a function. Execute this function as
and at
every one of your rotating armour stands:
execute at @p run summon armor_stand ~ ~ ~ {Tags:["temp"],Marker:1,Invisible:1,NoAI:1,NoGravity:1,Invulnerable:1}
data modify entity @e[type=armor_stand,tag=temp,limit=1] Pos[1] set from entity @s Pos[1]
tp @s ~ ~ ~ facing entity @e[type=armor_stand,tag=temp,limit=1]
kill @e[type=armor_stand,tag=temp]
The downside of this system is obviously that it's more complicated and that it requires access to the server files, for putting the datapack into the folder. There are certain configurations of player and armour stand positions in which you cannot perfectly select the correct position to look at, at least not for all in one tick, unless you use a function.
Correct answer by Fabian Röling on October 1, 2021
If I understand what you're both trying to accomplish in this Q&A, you can now (in JE 1.16.5) do this in one tidy command using execute, facing, and relative coordinates. I've taken the liberty of naming my armor stand "creepy" on account of it staring all the time.
/execute as @e[name=creepy, type=armor_stand] at @s facing entity @p eyes run tp @s ~ ~ ~ ~ 0
Answered by Telarly on October 1, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP