Use the plugin with Unity
This section describes how to use the Vicon VR for Unity plugin to stream data between Vicon software and Unity.
See the following documentation for more information on setting up:
- To set up Unity, see Set up Unity with the Vicon plugin.
- To set up your Vicon software, see Set up Vicon software to capture mocap data for use with Unity.
Stream data from a full body and retarget to a mesh in Unity
Use the plugin to stream movement data from a performer in a mocap suit to a humanoid character mesh in Unity.
Some applications of this functionality include:
- Creating realistic, complex animations for in-game characters, eg walking and dancing.
- Quickly prototyping level design and character movement in the context of your project.
- Live streaming data from players in a Virtual Reality (VR) environment to display in-game, eg in social VR environments.
To stream data from a full body to Unity:
-
Add a character mesh to the scene with the same skeleton as the Vicon solve or retarget .
This can be your own custom mesh, or one of the examples provided in Assets > ViconUnityPlugin > ViconSkins.
- In the Inspector, add a Subject Script component to the GameObject.
- Set the Subject Name field to the same name as the subject in the Vicon application.
- To set the Client, click and drag the ViconDataStreamClient prefab from the current scene into the entry field.
- Select the Play icon in Unity to see the plugin apply mocap animation data to the mesh.
To stream multiple subjects from the Vicon application to different meshes in Unity, duplicate the character GameObject and update the attached mesh and Subject Name as needed.
If you are having issues streaming full-body data to Unity, see Troubleshooting common issues or contact Vicon Support.
Stream data from a prop to a mesh in Unity
Use the plugin to stream movement data from a physical prop with mocap markers to a prop mesh in Unity.
Some applications include:
- Creating realistic character animations featuring props in Unity, eg sword fighting moves.
- Tracking physical props used by the player in Virtual Reality (VR) environments to translate the movement to their virtual counterparts, eg weapons and flashlights.
To stream data from a prop to Unity:
- Add a prop mesh to the scene. This can be your own custom mesh, or one of the examples provided in Assets > ViconUnityPlugin > PropMeshes.
- If an actor is interacting with the prop, set the prop as a child object of the actor.
- To set the prop as a child, go to the Inspector and drag and drop the prop GameObject onto the actor GameObject.
- In the Transform component of the prop, set all of the values to 0. It inherits new transform data from the actor to keep their position and rotation data in sync.
- In the Inspector, add the relevant plugin component to the GameObject:
- For single-segment skeletal props (recommended): add the SubjectScript component.
- For non-skeletal props: add the RBScript component.
- Set the Subject Name/Object Name field to the same name as the object in the Vicon application.
- To set the Client, click and drag the ViconDataStreamClient prefab from the current scene into the entry field.
- Select the Play icon in Unity to see the mocap animation data being applied to the mesh.
If you are having issues streaming prop data to Unity, see Troubleshooting common issues or contact Vicon Support.
Use a head-mounted display (HMD)
Use the plugin to stream location data from an HMD to Unity, and visual data from Unity to the HMD.
Some applications include:
- Tracking player location in Virtual Reality (VR) environments to allow them to move through the in-game world.
- Syncing the visual feed in the display with the Unity camera and motion capture data, so players can move their head and look around the in-game world.
- Add an HMDPrefab to the scene from Assets > ViconUnityPlugin > Prefabs.
- Open the PoseProvider child of the prefab in the Inspector.
- Go to the HMD Script component of the PoseProvider in the Inspector.
- Set the HMD field to the same name as the HMD object in the Vicon application.
- To set the Client, click and drag the ViconDataStreamClient prefab from the current scene into the entry field.
- Select the Play icon in Unity and put on your HMD to see the game world update as you look and move around the space.
If you are having issues using a head-mounted display (HMD) with Unity, see Troubleshooting common issues or contact Vicon Support.
These HMDs have been tested for use with the Vicon Unity plugin:
- Oculus Rift / Rift S
- HP Reverb
- HTC Vive / Vive Pro*
* Due to the requirements of the HTC headsets, they must also be visible by an HTC Vive Base Station.