鼠标点击从屏幕空间到世界:Convert Mouse Location To World Space + Line Trace¶
把鼠标当前的屏幕位置转换成世界空间的射线起点和方向,再用 Line Trace By Channel 检测点中的物体。
蓝图连法¶
- Get Player Controller(Player Index = 0)。
- Return Value 接 Convert Mouse Location To World Space(Target is Player Controller),输出 World Location 和 World Direction。
- World Direction × Make Literal Float(5000.0),再与 World Location 相加(+)得到射线终点。
- 接 Line Trace By Channel:
- Start = World Location
- End = World Location + World Direction × 5000
- Trace Channel = 可视性(Visibility)
- 输出 Out Hit 各项(Hit Actor、Hit Location 等)即可拿到点中的物体。
相关¶
- 若想固定从屏幕中心发射射线(准星玩法),见 鼠标点击射线检测(Deproject Screen to World)。
ID:29 | 更新:2026-06-11
