Skip to content
Janis Sprenger edited this page Dec 16, 2022 · 4 revisions

MOSIM Integration to a Unity Target Engine

This repository contains the integration of different tools and functionalities to support Unity as a target engine. The MOSIM Framework operates by simulating agent behavior and motion outside of the actual project, which hosts the rest of the simulation (e.g. the scene, other dynamic objects, etc.) and provides the central tick. Thus, please first start a deployed version of the MOSIM Framework on your machine.

Prerequisites

  • Unity Editor 2019.4.x or 2020.3.x or 2021.3.x
  • Visual Studio
  • A running version of the MOSIM Framework

An example of the MOSIM integration can be found at the MOSIM-Unity Repository.

To install the MOSIM framework to your Unity project, please add the following packages with the package manager. We recommend cloning and installing by a file path, as this allows for better debugging and development. It is, however, possible to directly install the packages from github. To install, open the package manager and click on the plus sign on the top left:

image

Initial Scene Setup

We assume, that there is a root game object. All of the children of the root game object can be tracked and connected to the MOSIM framework. This allows for additional game objects, which should not be considered by MOSIM (e.g. background objects). The root game object should contain the following components:

  • MMI Settings
  • Simulation Controller
  • Unity Scene Access
  • Main Thread Dispatcher

It is possible to automatically setting up the root object, by selecting it in the hierarchy with the right mouse button and selecting MMI/MakeSceneRoot

image

Setting up the Avatar

Each avatar in the scene needs to be connected using the "MMI Avatar" component. With this component, each avatar will register itself with the MOSIM framework and will be individually simulated as an agent by the behavior and motion simulation. The MOSIM framework will take over the simulation of this agent, including the full-body movements.

Please connect the Root Transform to the character's root (most likely the transform of the game object) and the pelvis transform to the transform of the pelvis joint. The MOSIM Framework utilizes a transfer skeleton to communicate movements between different components. To configure the retargeting solutions, please create a retargeting configuration file for your avatar using the Retargeting Configurator, copy it to your project and link it in the "Configuration File Path".

image
Parameter Description Example
Root Transform Unity Transform of the Avatar (not the root joint, but the object transform) Avatar (transform)
Pelvis First Joint of the Avatar (usually the pelvis) pelvis (transform)
Use Skeleton Visualization Display or hide the intermediate skeleton during the simulation On / Off
Game Joint Prefab Prefab used to display the intermediate skeleton. Not required if the intermediate skeleton is not displayed. singleBone
Configurations File Path Path to the retargeting configuration configurations/avatar.mos
Use Remote Co-Simulation Toggle to select whether to use an internal or remote co-simulator On / Off
Allow Remote Co-Simulation Access Toggle to select, whether external components (e.g. the behavior model) can access the internal co-simulator On / Off

Setting up Scene Objects

The MOSIM framework simulates humanoid avatars in a virtual environment. Hence, on the one hand, the Avatar has to be configured (see above). On the other hand, the scene has to be annotated in order for MMUs to interact with it. For this purpose, please add the MMI Scene Object Mono Behavior to every object, which should be visible in the MOSIM framework. Not all object and all geometry is transferred to the MOSIM Environment, only the ones annotated as MSceneObjects will be considered. In addition, all of these objects must be located in the hierarchy as a (sub-) child of root game object (see above) of MOSIM. It does not need to be a direct child, but inside the hierarchy, it needs to be a descendent (e.g. child of a child of the root object).

To make a Unity game object an MSceneObject, please either add the MSceneObject Monobehavior to the game object or utilize the UI, by selecting MMI -> Add MMISceneObjects on the object (see below).

Afterwards, all required game objects should have a MMI Scene Object component attached: