VR "touch screen" interaction

I just programmed that functionality into my game. So here is what I did:

I have a CollisionComponent that collides with WidgetComponents (Make sure the ‘UI’ Collision Profile is set up correctly). And I have a WidgetInteractionComponent with the InteractionSource set to Custom.

Every tick I am sweeping the CollisionComponent to where my finger is. The SweepHitResult is the set as the CustomHitResult for the WidgetInteractionComponent. Make sure the CollisionComponent is not attached to your MotionControllerComponent, otherwise the CollisionComponent will have been moved by the MotionControllerComponent already and performing the sweep will do nothing because of that.

After I set the CustomHitResult, I check whether the sweep hit a WidgetComponent and the WidgetInteractionComponent’s LastHitResult has the same WidgetComponent and the WidgetInteractionComponent IsOverHitTestVisibleWidget. If that is the case, I call PressPointerKey for the LeftMouseButton. Otherwise I call ReleasePointerKey for the LeftMouseButton.

The reason to check IsOverHitTestVisibleWidget is that it takes a tick or two for the WidgetInteractionComponent to fetch the widgets and PressPointerKey or ReleasePointerKey can not click any buttons, if the WidgetInteractionComponent is not OverHitTestVisibleWidget.

Hey guys, I’m hoping somebody can help me out with setting up vr “touch screen” interactions.

In my game, the player has a tablet that they can take out to access objectives, map, inventory etc. I want the player to be able to interact by touching the screen with the index finger on their virtual hand.

I’m not sure how to handle / set up this interaction though.

I was thinking I could use a Widget Interaction component, but I can’t figure out how to have it essentially ‘click’ the button without the player having to pull the trigger.

Other than that, I’m not sure how to progress. Any help would be really appreciated.

Using the Virtual Reality UE4 template.
Create a socket on the MannequinHand_Right skeleton asset.

261232-tshand1.png

In BP_MotionController, Create a WidgetInteraction and a Sphere collision component, have them attached to the Scene component. Set the sphere collision presets to UI.

261233-tshand2.png

Scale the sphere and WidgetInteraction to finger size.
I used (X=0.050000,Y=0.050000,Z=0.050000) for scale of the sphere and (X=0.500000,Y=0.200000,Z=0.200000) of the WidgetInteraction, I also set the interaction Distance to 25 of the WI.

261234-tshand3.png

Then at begin play use a timer by create event or use game tick to do this:

Then, do the begin and end overlap components:

And now you have your touch screen interaction finger.

See GitHub - DanielRBowen/MotionControllerVRTemplate: This is a UE4 VR template that supports motion controllers. It features a touch screen UI, teleporting, incremental teleport moving, and alternating fist movement. for a template that uses it.

I have a better VR template on GitHub: GitHub - DanielRBowen/UE4-VRHands-Template: This is a Unreal Engine 4 template for VR Headsets with motion controllers. It features dynamic hands, touch screens, grabbable objects, and locomotion.

A template with gamepad input as well: GitHub - DanielRBowen/UE4-VR-XPlatform-Menu: This is a VR template for UE4 that allows gamepad and motion controller input. The game can be set up for non-vr thirdperson games too.

That’s exactly what I want. Thank you.

It works for me,HAHA~

If your touch collision is a sphere and your widget is a plane you can do it accurately with overlap and line trace.

286352-annotation-2019-09-02-090424.png

Rotation does not matter for a sphere, and when it overlaps, do a line trace across two sides of the sphere in opposite direction of the widget component.

Blueprint

Do this every tick

TouchTheScreen

1 Like

I wonder when there is a new version, a lot of old blueprints don’t function anymore.