Difference between revisions of "Streaming to Unity"

From iPi Docs
Jump to: navigation, search
m
(Sample)
(One intermediate revision by the same user not shown)
Line 39: Line 39:
  
 
The sample project contains a simple scene with three characters. MocapStudioClient component is attached to '''Root''' object, and each of the character objects have CharacterAnimator component attached. To test the streaming:
 
The sample project contains a simple scene with three characters. MocapStudioClient component is attached to '''Root''' object, and each of the character objects have CharacterAnimator component attached. To test the streaming:
 +
* Open '''SampleScene''' (from Assets/Scenes) if it didn't show up automatically when you opened the project.
 
* Enable ''one'' of the characters in Unity.
 
* Enable ''one'' of the characters in Unity.
 
* Enter Play Mode.
 
* Enter Play Mode.

Revision as of 15:35, 8 October 2019

Note.png
Note: Feature is available in Basic and Pro editions only.

iPi Mocap Studio is capable of realtime streaming of character's pose over network. This can be used to preview captured motion in an actual game scene inside the Unity editor.

Usage in Mocap Studio

To start streaming, go to the Export tab and press Start Streaming button. While streaming is active any changes to a pose of the actor in Mocap Studio (playback, tracking, manual edit etc.) are sent to the local network. If there is a target character applied for an actor then the program streams poses of that target character otherwise it streams poses of the actor model. To stop streaming press Stop Streaming button on the Export tab. Streaming also stops automatically when a project is closed.

export-tab-streaming.png
Note.png
Note: Streaming of multiple actors is not currently supported. In multi-actor projects, it streams an active (currently selected) actor.

Streaming protocol broadcasts UDP packets to a certain port on the local network. By default, the port used is 31455. You can change this value in Streaming Settings dialog which opens when you press a "gear" icon on Start Streaming button.

streaming-settings-dialog.png
Tip.png
Tip: You may need to adjust firewall settings to allow outgoing connections to this UDP port.

Usage in Unity

To get data streamed by iPi Mocap Studio into Unity you need to add several C# scripts to your Unity project. You can download them from this link. This download contains necessary scripts under Scripts folder as well as a sample Unity project under Sample folder.

Scripts

MocapStudioClient component reads data from the network. Add it to some game object which is always active. It has properties:

  • Port (int) - the number of UDP port to listen for data from Mocap Studio. Should be equal to the value of UDP port set in the Streaming Settings in Mocap Studio. The default value is 31455.
    Tip.png
    Tip: You may need to adjust firewall settings to allow incoming UDP connections to this port.
Unity-MocapStudioClient-component.png

CharacterAnimator component applies motion data to a character. Add this component to a character game object. Position is applied to this game object and rotations are applied to game objects of skeleton joints which are descendants of the character. This component has properties:

  • Mocap Data (MocapStudioClient) - set to a game object holding MocapStudioClient component.
Unity-CharacterAnimator-component.png

Pose contains definition of the data structure used by the components.

Sample

The sample project contains a simple scene with three characters. MocapStudioClient component is attached to Root object, and each of the character objects have CharacterAnimator component attached. To test the streaming:

  • Open SampleScene (from Assets/Scenes) if it didn't show up automatically when you opened the project.
  • Enable one of the characters in Unity.
  • Enter Play Mode.
  • Import corresponding FBX model as target character into iPi Mocap Studio. FBX model files can be found under Sample\Assets\Characters directory (for Robot Kyle dive deeper to Robot Kyle\Model).
  • Load corresponding motion transfer profile into iPi Mocap Studio. .iPiTransfer files with profiles also reside under Sample\Assets\Characters directory.
  • Press Start Streaming button.
  • Then the character in Unity will follow motions of the character in iPi Mocap Studio.
streaming-to-unity-show-2.gif

Troubleshooting

Suppose you enter Play Mode in Unity and see the character stands still while it moves in iPi Mocap Studio. Probable reasons include:

  • You didn't start streaming in iPi Mocap Studio.
  • Either MocapStudioClient or CharacterAnimator components are not enabled in Unity.
  • Target character set in iPi Mocap Studio doesn't match a character used in Unity.
  • iPi Mocap Studio and MocapStudioClient component are set to use different ports for streaming.
  • Your firewall is blocking data transfer from iPi Mocap Studio to Unity.