Minecraft – How to make a Player only look in one direction

minecraft-commandsminecraft-java-edition

I am making a map for Minecraft and I want to make the Player only be able to face a certain wall.

Is there any way that I could do that?

Best Answer

You can achieve this with the /tp repeating. For example:

/tp @p ~ ~ ~ 90 0

The ~ ~ ~ means that their x, y and z won't be changed, but their yaw (left/right) will be set to 90 and their pitch (up/down) to 0.

You will need to put this command in a repeating command block or some other form of clock.