6. Unity Plugin

Importing Plugins

  1. Extract the plugin installation package for 'XINGYING_Unity_Plugin_XXXX. unitypackage', create a Unity project, click on Assets (17.6.1), and select 'Import package - CustomimPackage...', Import the extracted Unity plugin (17.6.2);

  2. The first time you import, there may be red compilation errors in the log panel. To fix this, open the project properties and set it to allow unsafe code. Check Edit > Project Settings > Player and enable "Allow Unsafe Code" (17.6.3);


Unity settings and usage

  1. Select "Assets > NOKOV > Scenes > NOKOVExample" in the imported installation package and double-click to open it (17.6.4);

  2. Click on "Client NOKOV" in the Hierarchy panel, modify the Host IP on the right to 10.1.1.198, and select "XINGYING" for Skeleton Naming Convention (17.6.5, 17.6.6). If the XINGYING software is playing glove human body data, please select "Xing Ying With Hand" for Skeleton Naming Convention.

  3. Click on "Sapphiart@walk" in the scene. Ensure that the three modules in the Inspector are checked, and that the name of the "Skeleton Asset Name" in "NOKOV Skeleton Animation (Script)" matches the name of the human body in XINGYING (17.6.7, 17.6.8). After making modifications, press Enter to save.

  4. Ensure that XINGYING software is in playback mode, then click the playback button in Unity to let the human body in XINGYING move. The model in Unity will then perform synchronous motion (17.6.9).

  5. Switch to the Scene view to observe the model from different angles (17.6.10).\


Display of Named and Unnamed Points

  1. In Unity, click on "Client-NOKOV" and check the "Draw Unlabeled Markers" checkbox (17.6.11). Then click the "Play" button at the top of the Unity software, and unnamed points will be displayed in the Unity scene.

  2. Check the "Draw Markers" checkbox (17.6.12), then click the "Play" button, and the named points of the human body will be displayed in the Unity scene.

  3. After expanding "Client-NOKOV," the list will show the IDs of both named and unnamed points. After selecting the ID name of a named or unnamed point from the list, you can view the position of the named or unnamed point in the Unity scene, and the XYZ coordinates of the selected point will be displayed on the right (17.6.13).

  4. Dropdown to Select Scale Ratio, Dropdown to Select Up Axis: Click on "Client-NOKOV," and on the right side, click on "Length Unit" to expand the dropdown and select the scale ratio (17.6.14). You can choose among "meter, Centimeter, Millimeter" for scaling objects in the Unity scene, with the default unit being "Meter." Click on the "Up Axis" option to expand the dropdown box where you can choose the up axis for the Unity scene, with the options being "Y, Z." The default up axis is "Y."


Access VRPN Handle in Unity

  1. First, follow the instructions in "17. Handle Connection Instructions and VRPN Data Access UE Instructions" to set up the connection and dynamic capture of the handle.

  2. Attach reflective markers to the object to be captured and create a rigid body in Live mode using XINGYING software.

  3. Open Unity and create a new project.

  4. Drag the plugin into the "Assets" folder (17.6.11), click "Import" to import it, then double-click "Demo" in the "Assets - UVRPN - Sensors" directory to enter the Unity scene (17.6.12) and switch to "Sense" (17.6.13).

  5. Parameter settings:

    • Set the local address: In "VRPN-Manager, " set the "Host: (IP/localhost)" address to "127.0.0.1" (17.6.14). If connecting to another host, change the IP address to the server IP address of the other host. After setting the IP, press Enter and Ctrl+S to save.

    • Turn on logging: Enabling logging allows you to see detailed information about the pressed buttons on the handle. Printing the error log can help identify and resolve issues. Select 'Window > General > Console' and check 'Debug Log' (17.6.15).

    • Set Flystick: Click on "Flystick" and enter the name of the rigid body created by VR Tracker software in the "Tracker" input box in the "VRPN_Tracker (Script)" module. Set "Channel" to 0 and press Enter to save (17.6.16).

    • In the "Tracker" input box of the "VRPN_Button (Script)" module, enter the name of the handle (joystick1, joystick2), check "Debug log" to facilitate printing of log information (17.6.17). If the first handle is connected, enter "joystick1" and press the Enter key. The "Channel" value here represents the number of the corresponding handle key position.

    • Enter the name of the handle (joystick1, joystick2) in the "Tracker" input box of the "VRPN_Analog (Script)" module, and set "Channel" to 0 (17.6.18).

  6. Real-time Drive Tracker

    • After all the above configurations are set, set the "Channel" value in the "VRPN_Button (Script)" module to 1, press the Enter key to save the configuration, click Play to switch to "Sense" to display the scene, and after moving the rigid body, the objects in Unity will also be synchronously driven. At this time, press the button numbered "1" on the handle, and the "Console" in Unity will print the information of the handle key position, Button 1 Hold "indicates that button 1 of the handle is pressed, and" Button 1 Up "indicates that button 1 of the handle is released after being pressed (17.6.19).

    • If you need to use other buttons on the handle, set the "Channel" value to the corresponding number in the "VRPN_Button (Script)" module.

    • If a handle wheel is used, there is no need to set it in the "Channel". Simply slide the wheel and the "Analog" coordinate value in the "VRPN_Analog (Script)" module will change in real time (17.6.20);

    • Inversion of displacement and rotation: When using a rigid body to drive objects in a Unity scene in Live, the displacement and rotation of the rigid body data can be reversed. In the "VRPN_Tracker (Script)" module, "Position Tracking" represents the displacement of the rigid body, "RotationTracking" represents the rotation of the rigid body, and checking "X, Y, Z" represents the inversion of the coordinate values of the "X, Y, Z" axes (17.6.21).