/camera 命令
图片处理:未转载源站游戏图像;具体物品、实体、效果或界面说明以中文文字保留。
来源:Commands/camera,英文修订 ID:3871371。
修改玩家的摄像机视角。此命令仅适用于基岩版与 Minecraft Education,所需权限等级为 1,需要启用作弊。不要与 /camerashake 混淆。
语法
主语法树:
/camera <players: target> ...
... attach_to_entity <entity: target>
... clear
... detach_from_entity
... fade ...
... color <red: int> <green: int> <blue: int>
... time <fadeInSeconds: float> <holdSeconds: float> <fadeOutSeconds: float> ...
... [color <red: int> <green: int> <blue: int>]
... fov_clear [fovEaseTime: float] [fovEaseType: Easing]
... fov_set <fov_value: float> [fovEaseTime: float] [fovEaseType: Easing]
... play_spline <name: string>
... remove_target
... set <preset: string> ...
... [default: default]
... ease <easeTime: float> <easeType: Easing> ...
... [default: default]
... facing ...
... <lookAtEntity: target>
... <lookAtPosition: x y z>
... pos <position: x y z> ...
... [facing ...]
... <lookAtEntity: target>
... <lookAtPosition: x y z>
... rot <xRot: value> <yRot: value>
... rot <xRot: value> <yRot: value>
... entity_offset <xEntityOffset: float> <yEntityOffset: float> <zEntityOffset: float>
... facing ...
... <lookAtEntity: target>
... <lookAtPosition: x y z>
... pos <position: x y z> ...
... [facing ...]
... <lookAtEntity: target>
... <lookAtPosition: x y z>
... rot <xRot: value> <yRot: value>
... rot <xRot: value> <yRot: value> ...
... entity_offset <xEntityOffset: float> <yEntityOffset: float> <zEntityOffset: float>
... view_offset <xViewOffset: float> <yViewOffset: float> ...
... entity_offset <xEntityOffset: float> <yEntityOffset: float> <zEntityOffset: float>
... view_offset <xViewOffset: float> <yViewOffset: float> ...
... entity_offset <xEntityOffset: float> <yEntityOffset: float> <zEntityOffset: float>
... target_entity <entity: target> ...
... [target_center_offset <xTargetCenterOffset: float> <yTargetCenterOffset: float> <zTargetCenterOffset: float>]
简化树:
camera <players: target> ...
... attach_to_entity <entity: target>
... clear
... detach_from_entity
... fade ...
... color <red: int> <green: int> <blue: int>
... time <fadeInSeconds: float> <holdSeconds: float> <fadeOutSeconds: float> [color <red: int> <green: int> <blue: int>]
... fov_clear [fovEaseTime: float] [fovEaseType: Easing]
... fov_set <fov_value: float> [fovEaseTime: float] [fovEaseType: Easing]
... play_spline <name: string>
... remove_target
... set <preset: string> ...
... [default: default]
... ease <easeTime: float> <easeType: Easing> ...
... [default: default]
... facing <lookAtEntity: target>
... facing <lookAtPosition: x y z>
... pos <position: x y z> ...
... [facing <lookAtEntity: target>]
... facing <lookAtPosition: x y z>
... rot <xRot: value> <yRot: value>
... rot <xRot: value> <yRot: value>
... entity_offset <xEntityOffset: float> <yEntityOffset: float> <zEntityOffset: float>
... facing <lookAtEntity: target>
... facing <lookAtPosition: x y z>
... pos <position: x y z> ...
... [facing <lookAtEntity: target>]
... facing <lookAtPosition: x y z>
... rot <xRot: value> <yRot: value>
... rot <xRot: value> <yRot: value> [view_offset <xViewOffset: float> <yViewOffset: float>] ...
... entity_offset <xEntityOffset: float> <yEntityOffset: float> <zEntityOffset: float>
... view_offset <xViewOffset: float> <yViewOffset: float> [entity_offset <xEntityOffset: float> <yEntityOffset: float> <zEntityOffset: float>]
... target_entity <entity: target> [target_center_offset <xTargetCenterOffset: float> <yTargetCenterOffset: float> <zTargetCenterOffset: float>]
最简树:
camera <players: target> ...
... clear
... fade [color <red: int> <green: int> <blue: int>|time <fadeInSeconds: float> <holdSeconds: float> <fadeOutSeconds: float> [color <red: int> <green: int> <blue: int>]]
... remove_target
... set <preset: string> ...
... [default: default]
... ease <easeTime: float> <easeType: Easing> ...
... [default: default]
... facing <<lookAtEntity: target>|<lookAtPosition: x y z>>
... pos <position: x y z> [facing <<lookAtEntity: target>|<lookAtPosition: x y z>>|rot <xRot: value> <yRot: value>]
... rot <xRot: value> <yRot: value>
... entity_offset <xEntityOffset: float> <yEntityOffset: float> <zEntityOffset: float>
... facing <<lookAtEntity: target>|<lookAtPosition: x y z>>
... pos <position: x y z> [facing <<lookAtEntity: target>|<lookAtPosition: x y z>>|rot <xRot: value> <yRot: value>]
... rot <xRot: value> <yRot: value> [view_offset <xViewOffset: float> <yViewOffset: float>] ...
... entity_offset <xEntityOffset: float> <yEntityOffset: float> <zEntityOffset: float>
... view_offset <xViewOffset: float> <yViewOffset: float> ...
... entity_offset <xEntityOffset: float> <yEntityOffset: float> <zEntityOffset: float>
... target_entity <entity: target> [target_center_offset <xTargetCenterOffset: float> <yTargetCenterOffset: float> <zTargetCenterOffset: float>]
完整展开形式:
camera <players: target> attach_to_entity <entity: target>
camera <players: target> clear
camera <players: target> detach_from_entity
camera <players: target> fade
camera <players: target> fade color <red: int> <green: int> <blue: int>
camera <players: target> fade time <fadeInSeconds: float> <holdSeconds: float> <fadeOutSeconds: float>
camera <players: target> fade time <fadeInSeconds: float> <holdSeconds: float> <fadeOutSeconds: float> color <red: int> <green: int> <blue: int>
camera <players: target> remove_target
camera <players: target> set <preset: string> [default: default]
camera <players: target> set <preset: string> ease <easeTime: float> <easeType: Easing> [default: default]
camera <players: target> set <preset: string> ease <easeTime: float> <easeType: Easing> facing <lookAtEntity: target>
camera <players: target> set <preset: string> ease <easeTime: float> <easeType: Easing> facing <lookAtPosition: x y z>
camera <players: target> set <preset: string> ease <easeTime: float> <easeType: Easing> pos <position: x y z>
camera <players: target> set <preset: string> ease <easeTime: float> <easeType: Easing> pos <position: x y z> facing <lookAtEntity: target>
camera <players: target> set <preset: string> ease <easeTime: float> <easeType: Easing> pos <position: x y z> facing <lookAtPosition: x y z>
camera <players: target> set <preset: string> ease <easeTime: float> <easeType: Easing> pos <position: x y z> rot <xRot: value> <yRot: value>
camera <players: target> set <preset: string> ease <easeTime: float> <easeType: Easing> rot <xRot: value> <yRot: value>
camera <players: target> set <preset: string> entity_offset <xEntityOffset: float> <yEntityOffset: float> <zEntityOffset: float>
camera <players: target> set <preset: string> facing <lookAtEntity: target>
camera <players: target> set <preset: string> facing <lookAtPosition: x y z>
camera <players: target> set <preset: string> pos <position: x y z>
camera <players: target> set <preset: string> pos <position: x y z> facing <lookAtEntity: target>
camera <players: target> set <preset: string> pos <position: x y z> facing <lookAtPosition: x y z>
camera <players: target> set <preset: string> pos <position: x y z> rot <xRot: value> <yRot: value>
camera <players: target> set <preset: string> rot <xRot: value> <yRot: value>
camera <players: target> set <preset: string> rot <xRot: value> <yRot: value> entity_offset <xEntityOffset: float> <yEntityOffset: float> <zEntityOffset: float>
camera <players: target> set <preset: string> rot <xRot: value> <yRot: value> view_offset <xViewOffset: float> <yViewOffset: float>
camera <players: target> set <preset: string> rot <xRot: value> <yRot: value> view_offset <xViewOffset: float> <yViewOffset: float> entity_offset <xEntityOffset: float> <yEntityOffset: float> <zEntityOffset: float>
camera <players: target> set <preset: string> view_offset <xViewOffset: float> <yViewOffset: float>
camera <players: target> set <preset: string> view_offset <xViewOffset: float> <yViewOffset: float> entity_offset <xEntityOffset: float> <yEntityOffset: float> <zEntityOffset: float>
camera <players: target> target_entity <entity: target>
camera <players: target> target_entity <entity: target> target_center_offset <xTargetCenterOffset: float> <yTargetCenterOffset: float> <zTargetCenterOffset: float>
原文不同形式的语法树存在更新不同步的情况:最简树和完整展开形式未列出主语法树中的部分新分支。这里完整保留各形式。
参数
原文提示本节仍需要补充资料。
players: target(CommandSelector<Player>):要修改摄像机的玩家,可使用玩家名称或目标选择器。
entity: target(CommandSelector<Actor>,attach_to_entity):摄像机要附着到的实体,可使用名称或目标选择器。
red: int、green: int、blue: int:摄像机覆盖层的 RGB 颜色,各为 0 至 255 的整数(含边界)。淡入结束后覆盖层完全不透明,不能指定半透明值。一次渐变期间颜色保持不变,新命令给出的颜色会被忽略。省略 color 时默认 0 0 0,即黑色。
fadeInSeconds: float、holdSeconds: float、fadeOutSeconds: float:淡入、保持、淡出的秒数,各必须为 0.0 至 10.0 的浮点数(含边界)。已有渐变正在播放时,新命令与其合并:淡入用两者较快的时间,淡出的开始和结束使用两者较晚的时间;透明度从当前值开始,颜色使用正在播放的渐变颜色。单次命令三个阶段各不得超过 10 秒,但合并后的总时长可以超过 10 秒。若三个阶段之和不足 0.5 秒,则延长保持阶段以补足 0.5 秒。省略 time 时默认 1 0.5 1。
fov_value: float:摄像机视场角(FOV)。必须为浮点数;受游戏限制,实际有效范围为 30 至 110(含边界)。
fovEaseTime: float:FOV 平滑过渡的持续秒数,默认 0,必须为浮点数。
fovEaseType: Easing:FOV 使用的缓动函数,默认 linear。
name: string:样条 ID,仅在 minecraft:free 预设下有效。必须为字符串;含空格时用双引号包围。
preset: string:摄像机视角/预设。原文此参数仍标记为需要补充资料。可选值:
| 预设 | 视角 |
|---|---|
minecraft:control_scheme_camera |
控制方案摄像机,需要“实验性创作者摄像机功能” |
minecraft:first_person |
第一人称 |
minecraft:fixed_boom |
固定悬臂的环绕摄像机 |
minecraft:follow_orbit |
环绕摄像机 |
minecraft:free |
自由视角 |
minecraft:third_person |
第三人称背面 |
minecraft:third_person_front |
第三人称正面 |
easeTime: float:摄像机平滑过渡的持续秒数,仅 minecraft:free 预设有效,必须为浮点数。
easeType: Easing:摄像机缓动函数,仅 minecraft:free 预设有效。它与 fovEaseType 均必须为下列值之一:
in_back in_bounce in_circ in_cubic in_elastic in_expo
in_out_back in_out_bounce in_out_circ in_out_cubic in_out_elastic in_out_expo
in_out_quad in_out_quart in_out_quint in_out_sine
in_quad in_quart in_quint in_sine linear
out_back out_bounce out_circ out_cubic out_elastic out_expo
out_quad out_quart out_quint out_sine spring
default: default:把自由视角的位置和朝向改为默认值,原文给出摄像机位置 (0,0,0)、xRot=0、yRot=0。但原文同时提示:默认位置和朝向不稳定,会对应 JSON 文件中的位置与朝向,仍需查明这种不稳定的原因。仅 minecraft:free 有效,值必须为 default。
lookAtEntity: target(CommandSelector<Actor>):摄像机朝向的实体,仅 minecraft:free 有效,可用实体名称或目标选择器。
lookAtPosition: x y z(CommandPositionFloat):摄像机朝向的坐标,仅 minecraft:free 有效。由三个数值组成,可用波浪号或插入符相对坐标。
position: x y z(CommandPosition):摄像机位置,仅 minecraft:free 有效。由三个坐标组成,可用波浪号或插入符相对坐标。
xRot: value(RelativeFloat):摄像机竖直旋转角。在 minecraft:follow_orbit 下也会修改玩家朝向。可用浮点数或波浪号相对值;原文规定范围为 -90 至 0(含边界)。
yRot: value(RelativeFloat):摄像机水平旋转角。在 minecraft:follow_orbit 下也会修改玩家朝向。可用浮点数或波浪号相对值。
xViewOffset: float、yViewOffset: float:摄像机偏移,仅 minecraft:follow_orbit 有效,各为 -64 至 64 的浮点数(含边界)。
xEntityOffset: float、yEntityOffset: float、zEntityOffset: float:摄像机相对于实体的偏移,仅 minecraft:follow_orbit 有效,各为 -64 至 64 的浮点数(含边界)。
entity: target(CommandSelector<Actor>,target_entity):摄像机聚焦的实体,仅 minecraft:free 有效,可用名称或目标选择器。
xTargetCenterOffset: float、yTargetCenterOffset: float、zTargetCenterOffset: float:摄像机相对于聚焦/目标实体中心的偏移,仅 minecraft:free 有效,均为浮点数。
结果
参数指定错误时无法解析。以下情况失败:
players: target未解析为一个或多个在线玩家。entity: target或lookAtEntity: target未解析为实体;以名称指定的玩家必须在线。fov_clear或fov_set中,fovEaseTime: float不大于0。此条件与该参数默认值为0的说明存在表面冲突,按来源保留。
其他情况成功。
输出
失败时成功次数为 0,成功时为选中的玩家数量。
示例
原文提示本节仍需要补充资料。
把自己的自由视角摄像机放在当前位置上方 5 格,绕 X 轴转 90 度,以 in_out_circ 缓动,过渡持续 5 秒:
/camera @s set minecraft:free ease 5 in_out_circ pos ~ ~5 ~ rot 90 0
该示例的 90 与上方 xRot 参数范围不一致;原文如此,未擅自改动。
清除所有玩家的摄像机效果:
/camera @a clear
随机玩家的摄像机在 2 秒内淡入白色,保持 1 秒,再用 3 秒淡出:
/camera @r fade time 2 1 3 color 255 255 255
配合 /execute 为最近玩家设置越肩视角,必须在循环型命令方块中执行:
/execute as @p at @s run camera @s set minecraft:free ease 0.25 in_out_quad pos ^-2 ^2 ^-4 facing ^ ^ ^5
先渐变,再传送玩家,以隐藏传送过程:
/camera @a fade time 0.5 0.5 0.5
/tp @a 100 64 100
参考资料
- Microsoft Learn:摄像机系统介绍,其中的“组合渐变”和“渐变限制”章节。
- 原文历史部分另引用了已修复问题 MCPE-173524。
外部链接
- Microsoft Learn:
/camera命令,2025-04-03。
本文为 Minecraft Wiki 对应英文条目的中文翻译与改编,已按要求省略变更历史。原作者与贡献者见来源页及其历史;除另有说明外,按 CC BY-NC-SA 3.0 非商业、署名、相同方式共享。