Language:
Page Info
Tags:
Skill Level:
Engine Version:

Use the GoogleVR Touchpad

Choose your OS:
Prerequisite Topics

This page assumes you have prior knowledge of the following topics. Please read them before proceeding.

HTGVRMCTouchpad_Hero_Image.png

Due to the highly-accurate nature of the GoogleVR Motion Controller (MC) Touchpad, it can be used to perform all kinds of different interactions that require high precision. From scrolling through a series of menu options or trying to plot your precise location on a map, there is an almost endless amount of ways to use the Touchpad to interact with the virtual world. In the following How-To, we will take a look at how to get and then display the current location that is being touched on the GoogleVR Motion Controller Touchpad.

In this How-To we will be starting with a Pawn that already has a VR Camera and Motion Controller support added to it. If you do not have this setup, please check out the documents listed in the Prerequisite Topics list at the top of this page.

Steps

In the following section we will take a look at setting up the touchpad on the Google Daydream Motion controller.

  1. First, open up your player Pawn Blueprint. From the Component tab, add two new Text Render components, called X_Position and Y_Position. Make sure that both are parented to the GoogleVRMotion Controller component like in the image below.

    HTGVRMCTouchpad_00.png

  2. Click on the Text Component, and then set the following properties with the following values for both the X and Y text in the Details Panel:

    Click for full image. Note that this is only showing the Y_Position properties. See table below for X_Position properties.

    Property Name

    Value

    Location X Text

    X = 20, Y = 0, Z = 0

    Location Y Text

    X = 20, Y = 0, Z = 5

    Rotation X & Y

    X = 20, Y = 0, Z = -180

    Horizontal Alignment X & Y

    Center

    Vertical Alignment X & Y

    Text Center

    World Size X & Y

    5

  3. Before we can build the logic for the Blueprint, we first need to create two variables to hold and display the X and Y input location on the Touchpad. Go to the Variables section, add two new Text Variables called XPositionText and YPositionText.

    HTGVRMCTouchpad_02.png

  4. To display the current location that is being pressed on the Touchpad, we will first need to get and then store the X and Y Axis Value of the current touch input. Then, using the Set Text node we can display that information via the Text Render Component that we added to our GoogleVR Motion Controller. To do this in our Blueprint, add the following nodes and variables to the Event Graph:

    Click for full image.

    Node / Variable Name

    Value

    MotionController(R)Thumbstick X

    N/A

    ToText(Float)

    N/A

    SET_ XPosition_Text(Float)

    N/A

    Set Text

    N/A

    X_Positiont

    N/A

    XPositionText

    N/A

    Append

    A Input: X:

    ToText(string)

    N/A

  5. Next, we need to build the logic that will display the input location using the text that was attached to the Motion Controller. To do this, we will need to get the Axis Value of the MotionController (R)Thumbstick X and store that in the XPositionText variable. Once we have that information, we can then display this value using the X_Postion text. When completed, your Blueprint should look like the following image:

    Copy Node Graph

    Click image to copy Blueprint code.

  6. Now that we have the X axis input value, to get the Y axis input value, we can use the same logic, but we need to change the MotionController(R)Thumbstick and variables to use the Y axis. When completed, your entire Blueprint should look like the following image:

    Copy Node Graph

    Click image to copy Blueprint code.

  7. Next, we need to attach the two Text Render Components to GoogleVR MC so that they will follow it when moved. To do this in our Blueprint, add the following nodes to the Event Graph and then connect them to match the following image:

    Node / Variable Name

    Value

    AttachToComponent

    N/A

    X_Position

    N/A

    Y_Position

    N/A

    Get Motion Controller

    N/A

    Google Motion Controller

    N/A

End Results

Once the Blueprint has been compiled and saved, and the project has been deployed to your smartphone, pick up your GoogleVR HMD and Motion Controller. Now, when you touch the Touchpad, you should see the numbers update with the location that you are currently touching, like in the following video:

Unreal Engine Project Downloads

Below, you will find a link to where you can download the Unreal Engine project that was used to create this example.

Tags