2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【UE5】マウスの動きに合わせてカメラが動く条件メモ

Last updated at Posted at 2025-04-22

Mouse Capture の扱い(FirstPerson 視点時)

🎯 概要

UE5 において、マウス移動でカメラが動く処理(FirstPerson等)に関係するのは Mouse Capture の設定です。

✅ マウスキャプチャを制御する主要ノード

ノード名 概要 備考
Show Mouse Cursor マウスカーソルの表示/非表示を切り替え UI操作時は通常 true、操作時は false。カーソル表示中は原則キャプチャされません。
Set Input Mode (GameOnly / UIOnly / GameAndUI) 入力モードを切り替える ※これらは 内部で CaptureMode を強制変更する点に注意
Set Viewport Mouse Capture Mode キャプチャモードを直接指定 SetInputMode のあとに呼ばないと上書きされるので無効化される可能性あり
Set Ignore Look Input 視点移動を一時無効 SetInputMode のあとに呼ばないと上書きされるので無効化される可能性あり

image.png


⚠ 注意:InputMode が CaptureMode を上書きする

以下のような順序で呼ばないと、思ったとおりに動作しない可能性があります:

【間違いの例】
SetViewportMouseCaptureMode → SetInputMode → ❌ CaptureModeが上書きされる

【正しい順序】
SetInputMode(GameOnly 等) → SetViewportMouseCaptureMode(CapturePermanently_IncludingInitialMouseDown)
→ ShowMouseCursor(false)

🎮 よく使う組み合わせ

▶ プレイアブル状態に移行(視点操作あり)

SetInputMode(GameOnly)
SetViewportMouseCaptureMode(CapturePermanently_IncludingInitialMouseDown)
ShowMouseCursor(false)

▶ UIのみ操作(ポーズメニューなど)

SetInputMode(UIOnly)
ShowMouseCursor(true)

▶ ゲーム中に一時的に視点操作だけ無効化したいとき

PlayerController->SetIgnoreLookInput(true);  // 視点入力だけ無視

📌 補足

  • CaptureMode の値は以下のようなものがある:

    • NoCapture
    • CapturePermanently
    • CapturePermanently_IncludingInitialMouseDown ← 一番安定する
    • CaptureDuringMouseDown
    • CaptureDuringRightMouseDown
  • SetInputModeGameOnly() などは BP でも使えるが、マウスキャプチャまで完全に制御したいなら直後に SetMouseCaptureMode() を呼ぶのが鉄則

🔑 要点:「InputMode → CaptureMode の順に設定」さえ守れば OK。

📚参照

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?