TransWikia.com

How to detect when a player looks at a pig with name "173"

Arqade Asked by Tech Glitch on January 26, 2021

I tried this:

/execute if entity @e[type=minecraft:player] facing entity @e[type=minecraft:pig,tag=173] feet run say hello

But it didn’t work.

One Answer

facing is completely separate from if entity <selector>, it just changes how the command is run (with a different rotation). Detecting if a player looks at something is very hard and requires something called "raytracing" (one example is here).
It might be possible to somehow check if the player looks at an enderman, but even if they're "invisible", you can still see the eyes, so that's probably not what you want.

I recommend changing something else about your setup so that you don't require to check for looking at a pig.

Answered by Fabian Röling on January 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP