Minecraft Bedrock Edition – How to Detect When an Arrow Faces a Player

minecraft-bedrock-editionminecraft-commands

I'm trying to make it so that when I fire a bow it instantly kills the person I'm looking at, I know to do that I need to know where the arrow is facing and I have no clue how to do that.

Best Answer

If you need the arrow's direction to see if it will hit an entity to then kill it (as though you were looking at it), it would be the same as if it was you or any player, but it's with the arrow: in a repeating command block put /execute @e[type=arrow] ^ ^ ^1 execute @e[r=1] ~ ~ ~ kill @s. The ^ is taking where the entity is looking, so the ^ ^ ^1 is asking for the location where the arrow is facing. If you want the detection to last longer, you would need to duplicate the command, either into another command block or into a repeating function if you're making a behavior pack, and increase ^ ^ ^1 to ^ ^ ^2, etc.

Related Topic