プレイヤーが「どこを見ているか」で発動する仕掛け。目線のレーザーや、宝の方向を教えるナビにも使えます。
統合版/BEJava版
答えだけ先に
anchored eyes で基準を目の高さに上げて、^(前・上・左の座標)で目線の先を指すだけ。
01
基本のかたち
^ は向いている方向が基準。書く順番は ^左 ^上 ^前。
目線の2ブロック先に炎を出すJava版
execute as @a at @s anchored eyes run particle minecraft:flame ^ ^ ^2 0 0 0 0 1
目線の2ブロック先に炎を出す(統合版/BE)統合版/BE
execute as @a at @s anchored eyes run particle minecraft:basic_flame_particle ^ ^ ^2
メモanchored eyes がないと基準が足元のまま。目線を扱うときは必ず付ける。戻すときは anchored feet。
02
よく使う例
距離を変えたチェーンを並べると、点が線に見えてレーザーになる。
宝の方向を光で教える(目的地は 100 64 100/Java版)Java版
execute as @a at @s anchored eyes facing 100 64 100 run particle minecraft:happy_villager ^ ^ ^2 0 0 0 0 1
宝の方向を光で教える(統合版/BE)統合版/BE
execute as @a at @s anchored eyes facing 100 64 100 run particle minecraft:villager_happy ^ ^ ^2
見たら発動(Java版)Java版
execute as @a at @s anchored eyes facing 100 64 100 anchored feet positioned ^ ^ ^1 rotated as @s positioned ^ ^ ^-1 if entity @s[distance=..0.1] run say 見ています!
見たら発動(統合版/BE)統合版/BE
execute as @a at @s anchored eyes facing 100 64 100 positioned ~ ~-1.62 ~ positioned ^ ^ ^1 rotated as @s positioned ^ ^ ^-1 if entity @s[r=0.2] run say 見ています!
注意facing entity でモブを指すときは、うしろに eyes か feet を必ず書く。省くとエラーになる。座標を指す facing 100 64 100 では要らない。
03
パラメータ早見
facing と anchored で「どこを見ているか」を指定する。
| 書き方 | 意味 |
|---|---|
^ ^ ^3
|
目線の方向へ3ブロック前 |
^1 ^ ^
|
左へ1ブロック |
^ ^1 ^
|
真上へ1ブロック |
anchored eyes
|
基準を目の高さに上げる |
facing <座標>
|
その場所のほうを向いた状態にする |
rotated as @s
|
向きを本人の本当の向きに戻す |
| 判定の数字 | だいたいの視野角 | 使いどころ |
|---|---|---|
0.1
|
約6度 | ピンポイント。小さな的に |
0.2
|
約12度 | 標準。像や看板に |
0.5
|
約29度 | ゆるめ。視界に入ればOK |
1.0
|
約60度 | かなりゆるい |
注意1.0 を超える値は使わない。判定が広がりすぎて、後ろを向いていても反応することがある。まずは 0.2 から。
04
Java版と統合版のちがい
見たら発動の式は、真ん中の1行だけが違う。
Java版
-
基準を足元に戻すのは
anchored feet -
判定は
if entity @s[distance=..0.1] -
モブ指定は
@e[type=zombie,limit=1,sort=nearest]
統合版/BE
-
anchoredは1回しか効かないので、positioned ~ ~-1.62 ~で自力で下げる(省略も数字の変更も不可) -
判定は
if entity @s[r=0.2] -
モブ指定は
@e[type=zombie,c=1]