# エージェントにインタラクトさせる(agent.interact) > (右クリックしたように)操作する。 - カテゴリ:エージェント(agent) - ブロック:エージェントをSixDirection.Forwardに向けてインタラクトさせる - URL:https://makecode.minecraft-okinawa.com/reference/agent/interact/ - 公式データ取得日:2026-11-13 - 動作確認:確認待ち ## JavaScript ```javascript agent.interact(SixDirection.Forward) ``` ## Python ```python agent.interact(FORWARD) ``` ## 引数 | 名前 | 値 | 意味 | |---|---|---| | direction | 方向 | アイテムを置く方向。たとえば:SixDirection.Back | ## 使用例 ### Make two chat commands. One has the agent teleport to the player and then place a dark oak door from an inventory slot. The other chat command has the agent open and walk through the door. ```javascript player.onChat("placedoor", function () { agent.teleportToPlayer() agent.setItem(DARK_OAK_DOOR, 1, 1) agent.setSlot(1) agent.place(FORWARD) }) player.onChat("opendoor", function () { agent.interact(FORWARD) agent.move(FORWARD, 2) }) ``` ```python def on_on_chat(): agent.teleport_to_player() agent.set_item(DARK_OAK_DOOR, 1, 1) agent.set_slot(1) agent.place(FORWARD) player.on_chat("placedoor", on_on_chat) def on_on_chat2(): agent.interact(FORWARD) agent.move(FORWARD, 2) player.on_chat("opendoor", on_on_chat2) ``` ## 出典 - [MakeCode for Minecraft 公式リファレンス(agent.interact)](https://minecraft.makecode.com/reference/agent/interact) 執筆:鈴木孝昌(現役プロジェクトマネージャー/マイクラカップ指導者)/運営:沖縄マイクラ部 プログラミングスクール「クロスウェーブ」(https://minecraft-okinawa.com/)