Orbital Camera

Introduction

Sourced By Bedrock Commands Community Discord

This technique allows you to confine your camera rotations to an orbit around the player, an entity or position with the height and radius of the orbit being fully adjustable.

Video Demonstration

Command

mcfunctionCopy
yaml
/execute as @p at @s anchored eyes rotated ~ 0 positioned ^^1^-2 run camera @s set minecraft:free ease 0.1 linear pos ~~~ facing @s
1

commandBlockChain1

2D Visualisation:

OrbitCamVisualRep

Command Breakdown:

  • as @p
    • sets the execution target to closest player.
  • at @s
    • sets the execution position to the target player.
  • anchored eyes
    • brings the execution position up to the target player's eye level.
  • rotated ~ 0
    • sets the execution rotation relative to the target player's horizontal rotation but confines the vertical rotation to 0° (straight).
    • if you wish to lock the horizontal rotation instead, simply do: rotated 0 ~
      • note: value 0 can be changed to face the direction you need. Refer to Rotations for more info.
    • if you do not wish to lock the vertical rotation, simply omit this part altogether to get a full spherical rotation. However, this will not prevent the camera from going underground.
  • positioned ^^1^-2
    • pushes the execution position 1 block above the player and 2 blocks behind.
    • increase or decrease value 1 to increase / decrease orbit height.
    • increase or decrease value -2 to increase / decrease orbit radius.
      • Negative value will set the position behind the player.
      • Positive value will set the position in front of the player.
      • To learn more, refer to: Coordinates System
  • run camera @s set minecraft:free ease 0.1 linear pos ~~~
    • sets the camera for the target player with the minecraft:free preset with a linear ease value of 0.1 at relative coordinates (1 block above and 2 blocks behind from the target player's sight)
    • To adjust camera movement speed increase / decrease ease value 0.1
    • To learn about the /camera command and it's available options such as presets and ease, refer to the following resources:
  • facing @s
    • shifts the camera view direction to face the target player.

Similar Examples:

mcfunctionCopy
yaml
#To orbit camera around entity tagged with 'orbit_center'
/execute as @p at @e [tag=orbit_center] anchored eyes rotated as @s rotated ~ 0 positioned ^^1^-5 run camera @s set minecraft:free ease 0.1 linear pos ~~~ facing @e [tag=orbit_center]
1
2

commandBlockChain1

mcfunctionCopy
yaml
#To orbit camera around position 6 7 8
/execute as @p positioned 6 7 8 rotated as @s rotated ~ 0 positioned ^^1^-5 run camera @s set minecraft:free ease 0.1 linear pos ~~~ facing 6 7 8
1
2

commandBlockChain1

Contributors