I'm trying to detect when a player is looking at another player to re-create Dream's 'Speedrunner v Assassin' video with GeorgeNotFound, in which if George looks at Dream, Dream becomes frozen. I would do this in Java but my friend only has Bedrock.
Anyone know how to do this with command blocks?
12 Answers
On bedrock, you can still achieve a slightly sloppier version:
execute @a[tag=!assassin] ^^^1 detect ~~~ air 0 execute @a[tag=assassin,r=2] ~~~ tp @s @sUnfortunately, you'll have to copy and paste this command into chain conditional always active blocks attached to the original repeat always active command block, changing ^^^1 to ^^^2, ^^^3 etc. for each consecutive command block.
Set all that up, and any player who runs /tag @s add assassin will become an assassin and able to be frozen.
You'll probably also want to make another repeat always active command block with execute @a[c=1,tag=assassin] ~~~ clone [coordinates of all command blocks including this one] ~ 0 ~ so that the command blocks will move to the players so they can't just leave the area affected by the command block and not be frozen.
This would be possible in Java Edition, using clever modification of the /execute command. Unfortunately, /execute does not support this in Bedrock Edition, as commands are very limited.
Here is a command that would work in Java Edition:
execute as @a # For each player, at @s # start at their feet. anchored eyes # Looking through their eyes, facing <X Y Z> # face perfectly at the target anchored feet # (go back to the feet) positioned ^ ^ ^1 # and move one block forward. rotated as @s # Face the direction the player is actually facing, positioned ^ ^ ^-1 # and move one block back. if entity @s[distance=..0.6] # Check if we're close to the player's feet.
run say I'm facing the target!