Execute if facing a direction minecraft

In Minecraft, I'm creating a tube that is meant to take you up and down floors. The way I want to accomplish this is such that if you're facing down in the tube, you go down, and if you're facing up, you go up. My only issue is how to execute if an entity is facing a certain direction. I found execute if rotation and execute if facing, both seeming promising. If there's a way to make it react if the player if facing directly up, mindless of other rotations, that's good. If there's a way to make it work when facing an armor stand, that's good. I just want some way to detect whether a player is facing up or down. I have tried this:

/execute if entity player1 facing entity player2 feet run say command magic

This always would say command magic, whether or not player1 was facing player2's feet. I tried the same with eyes instead of feet, and it didn't work. Is there a way to do this?


Solution 1:

You need to use the x_rotation selector argument, see here: https://minecraft.gamepedia.com/Commands#Target_selector_arguments (archive)

You can filter players looking straight up with x_rotation=-90 and down with x_rotation=90.