Unreal Cookbook:VR应用中的焦点目标拾取

在目前的VR应用中,特别是Cardboard类游戏中,经常用到的一个功能就是“检测玩家视线焦点对准的物体”。在虚幻4中,我们可以使用Line Trace来非常方便的实现这一功能。

 

 

DEMO源代码

为了演示这个功能的实现方法,我制作一个简单的DEMO,源代码请从这里下载:

https://github.com/neil3d/UnrealCookBook

使用的引擎版本为:4.11.2

打开项目后,启动“FocusActor/FocusActorMap.umap”地图文件即可运行。

 

在这个DEMO中,当玩家视线对准杯子或者花瓶的时候,对象顶部会出现一个文字。

 

功能实现

在上述DEMO中,我使用“/Game/FocusActor/Blueprints/BP_FocusActor_Player”来实现视线检测的功能。

 

首先在Tick的时候进行LineTrace:

 

在Line Trace到可交互的物体后,使用一个OnFocusActor自定义事件,来处理焦点对象变化的逻辑:

 

 

 

 

上图代码的基本流程是:先调用老的FocusActor的LostFocus事件;再调用新的FocusActor的OnFocus事件。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
This is the eBook of the printed book and may not include any media, website access codes, or print supplements that may come packaged with the bound book. “With his YouTube channel, Mitch’s VR Lab, Mitch has helped thousands of people understand the foundations of locomotion and interaction mechanics with clear and concise UE4 videos. I’m thrilled that he has taken the time to bring all his knowledge and experience in working with Unreal Engine and Virtual Reality to the Unreal? Engine VR Cookbook…. Mitch is uniquely qualified to share this book with the world.” —Luis Cataldi, Unreal Engine Education, Epic Games, Inc. For game developers and visualization specialists, VR is the next amazing frontier to conquer—and Unreal Engine 4 is the ideal platform to conquer it with. Unreal ? Engine VR Cookbook is your complete, authoritative guide to building stunning experiences on any Unreal Engine 4-compatible VR hardware. Renowned VR developer and instructor Mitch McCaffrey brings together best practices, common interaction paradigms, specific guidance on implementing these paradigms in Unreal Engine, and practical guidance on choosing the right approaches for your project. McCaffrey’s tested “recipes” contain step-by-step instructions, while empowering you with concise explanations of the underlying theory and math. Whether you’re creating first-person shooters or relaxation simulators, the techniques McCaffrey explains help you get immediate results, as you gain “big picture” knowledge and master nuances that will help you succeed with any genre or project. Understand basic VR concepts and terminology Implement VR logic with Blueprint visual scripting Create basic VR projects with Oculus Rift, HTC Vive, Gear VR, Google VR, PSVR, and other environments Recognize and manage differences between seated and standing VR experiences Set up trace interactions and teleportation Work with UMG and 2D UIs Implement character inverse kinematics (IK) for head and hands Define ef

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值