Create Simple Game Objects1. We will begin this example with a new project then, in the Hierarchy screen, click on the Create button and then select Cube. This adds a Cube game object to the Scene. | ![]() |
2. In the Hierarchy screen, click on the Create button and then select Directional Light. This adds a light source to the Scene. | ![]() |
3. In the Assets screen, expand the RSUnityToolkit folder and then the Actions folder by double-clicking the folder icons. | ![]() |
4. The Actions folder contains a number of scripts that can be applied to game objects. Click on the TrackingAction script, then drag and drop it on the Cube game object in the Hierarchy screen | ![]()
![]()
|
5. Now, select Cube in the Hierarchy screen and verify Tracking Action (Script) is shown in the Inspector screen. | ![]() |
Configure Hand Tracking6. By default, Tracking Action is set to HandTracking and the Virtual World Box Dimensions are set to 100 for X, Y and Z. If you play the game at this point you will see the 3D depth camera’s LED turn on, indicating the camera has been activated. | ![]() |
7. If you raise your hand in front of the camera you will likely see the Cube game object shoot off the screen. This is because the Virtual World Box Dimensions are set so high. Change the Virtual World Box Dimensions to 10 for X, Y and Z. | ![]()
|
8. In the Scene view you will observe that the Virtual World Box, shown in red outlines, is now more constrained around the game object. | ![]() |
9. Run the game again. The Cube game object should now track your hand more closely within a more confined virtual space. | ![]() |
10. One thing you might notice is that the movement of the Cube game object is somewhat jittery. This can be smoothed by increasing the Smoothing Factor to 10 (from default 0). | ![]()
![]()
|
Configure Face Tracking11. The Cube game object can easily be changed to track the user’s face. Locate Tracking Action in the Inspector window and change the default from HandTracking to FaceTracking. | ![]()
![]()
|
12. Run the game and ensure your face is within the field of view of the camera. The movement of the game object should now track your face and rotate based on the user’s head orientation (roll, pitch and yaw). | ![]() |