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.
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 existing scripts
- 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
- Cube
- Add 3D elements
- 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
- Add element
The configuration of the Cube would look similar to the following image:
The input section would be similar to the following image:
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
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
- GitHub, HoloToolkit
- GitHub, HoloToolkit Unity
- El Bruno, How to Import the HoloToolkit Unity
- El Bruno, How to place a Hologram using AirTap and HoloToolkit
- El Bruno, Creating a menu with options with HoloToolkit
- El Bruno, Using voice commands to display a menu with HoloToolkit
- El Bruno, How to create a 3D text always visible using HoloToolkit
- El Bruno, How to create a HUD (3D text always visible without HoloToolkit)
- El Bruno, How to detect hands using HoloToolkit
- El Bruno, Windows 10, Xbox One Controller, Bluetooth and some lessons learned
- El Bruno, How to use Fire Buttons actions with an XBoxOne Controller
- El Bruno, HoloToolkit compiled packages for Unity3D in GitHub
- El Bruno, How to detect AirTap and Click actions using HoloToolkit
- El Bruno, Detect user hand interactions using #HoloToolkit
- Unity, Input Manager
- Unity, Input Class Reference
30 comments