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.
Arqade is a question and answer site for passionate videogamers on all platforms. It only takes a minute to sign up.Sign up to join this community
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.