This is about how to track the player. Normally, you can enable player tracking by setting a spawn point in the compass, but I want it to be displayed in the actionbar. You put a tag "main" on the player you want to display and a tag "target" on the player you want to track. Then, I want to use arrows "↑↓→←" from the player with the tag "main" in the direction of the player with the tag "target" who is somewhere in the east, west, south, north, south and west. More specifically, I would like to include northeast, southeast, southwest, and northwest in addition to east, west, south, and northwest. How can I do this?
What I have done so far: I was able to rotate by 22.5 degrees in y_rotation, up to creating 8 ranges, I just don't think this is the right thing to do: (
ver 1.19.4
I solved it, so I will write the solution. hope it helps someone!
Thanks to @Samstercraft and @Plagiatus, I was able to figure out what to do :) My y_rotation was not wasted either. lol
Here is how I did it:
After calculating the difference between each coordinate, I executed commands separately for each number using a function. Since there were two test numbers for x and y, and three numbers (-1, 0, 1) to display, I created 8 files using 2³.
execute if score @s pos.x matches 0 if score @s pos.z matches 1.. run ...
(pos.x and pos.y are calculated by subtracting "main" tags from "target" tags.)
Then, within each file, I detected 8 directions using y_rotation and was able to display the appropriate direction.
For example: execute if entity @s[y_rotation=-22.5..22.5] run title @s title "↑"