#Hololens – Moving and rotating holograms using an #XBoxOne Controller

Hello!

Now that I have already connected the XBoxOne controller to the Hololens and I wrote on how to use some code to work with it, today’s post will show some of the features of the HoloToolkit class “Game Controller Manipulator“.

This class allows us to do several things, without having to add a line of code:

  • Selecting and moving a hologram in the PoV of the user of Hololens
  • Rotate a hologram on its 3-axis

Here is an example of this class in use.

2017 03 02 Holo XboxOne Controller Rotate Move 01.gif

Important: I found an error which affects the performance on a final app. I need to define the “ControllerTriggerAxis” as a new input element to be used for the Game Controller script. The following steps fix the original ones.

We start with the basics with these steps

  • Create a 3D project in Unity3D
  • Configure project to support HoloLens projects
  • Clean Scene elements
  • Import HoloToolkit package
  •  Add
    • HololensCamera
    • SpatialMapping
      • Uncheck the property “Draw Visual Meshes”
    • DefaultCursor
    • InputManager
  • Add Empty element, Managers
    • Add existing scripts
      • Game Controller Manipulator
      • Check the option “Move Gaze Target”
  • Add Empty element, HoloCollection
    • Add 3D elements
      • Cube
        • Position, x:0 y:0 z:2
        • Rotation, x:0 y:0 z:0
        • Scale, x:0.3 y:0.3 z:0.3
  • Edit – project settings – Input
    • Add element
      • Name: ControllerLeftStickX
      • Gravity: 0
      • Dead: 0.19
      • Sensitivity: 1
      • Type: Joystick Axis
      • Axis: X Axis
    • Add element
      • Name: ControllerLeftStickY
      • Gravity: 0
      • Dead: 0.19
      • Sensitivity: 1
      • Type: Joystick Axis
      • Axis: Y Axis
    • Add element
      • Name: ControllerTriggerAxis
      • Gravity: 0
      • Dead: 0.19
      • Sensitivity: 1
      • Type: Joystick Axis
      • Axis: Y Axis

The configuration of the Cube would look similar to the following image:

clipboard04

The input section would be similar to the following image:

clipboard02

Now we see a little so you can make the script Game Controller Manipulator. The first thing we see is that it has the following properties

clipboard02

In these properties we use the custom values we add in the Input for the Project settings. The 2 latest properties are also important

  • “Rotate modifier button name” indicate the name of a button on the remote control of XboxOne. Fire2 corresponds with the B button on the controller. While we hold it and move the joystick on the remote control, the hologram that this pointed to with the Gaze, will rotate on their axes, X, and y Z.
  • If you select “Move Gaze Target” when you press the button “Fire 1” (A button on the controller) we can move the hologram selected using the joystick on the remote control.

In these 2 scenarios, we see how the properties of the class define what are the elements of Input that are used to move the object of work.

Finally, comment that this class can be used in 2 ways

  • If you select the option “Move Gaze Target”, the movement and rotation apply to a hologram that is pointing the Gaze.
  • If the script is attached to an element and the “Move Gaze Target” option is not selected, move and rotate options are applied to the element

Greetings @ Toronto

El Bruno

References

Advertisement

30 comments

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: