10.创建玩家 Context
场景查询可基于 Actor 类型生成一系列项目,但其并不会对 Context 执行此操作。因此,需要找到一种使玩家 Pawn 成为 Context 的方法,此时 EnvQueryContext_BlueprintBase 即可派上用场。
步骤
在 内容浏览器 中双击打开 PlayerContext 蓝图进行编辑。
覆盖 ProvideActorsSet 函数:
将鼠标悬停在 My Blueprint 面板中的 Functions 部分即可显示隐藏的 Override 按钮。
按下此按钮后,打开的蓝图图表将覆盖函数的默认行为:
添加一个 Get All Actors Of Class,然后以下图中的方式将其连接在 Provide Actor Set 节点和 ReturnNode 中间:
最后将 Get All Actors Of Class 节点的 Actor Class 设为 Top Down Character,然后 编译 并 保存。