Search Unity

Question Body Tracking, Change Body Model/Animator in Runtime

Discussion in 'Unity MARS' started by unity_QE9qONiuaZjjDg, Jan 1, 2022.

  1. unity_QE9qONiuaZjjDg

    unity_QE9qONiuaZjjDg

    Joined:
    Mar 25, 2020
    Posts:
    5
    Hello,

    I'm using MARS 1.4.1 body tracking which works fine, now i want to change the 3d model that being tracked on the human body in Runtime.

    For example, Start the scene with warrior model then build a function to change to Mage at runtime.

    Regards,
     
  2. CiaranWills

    CiaranWills

    Unity Technologies

    Joined:
    Apr 24, 2020
    Posts:
    199
    We looked into this, but are not sure it's possible to switch the model on a proxy at runtime unless we make some API changes (which we'll consider for a future patch).

    You might however be able to achieve this by having separate proxies for each model and activating/deactivating them as needed.
     
  3. unity_QE9qONiuaZjjDg

    unity_QE9qONiuaZjjDg

    Joined:
    Mar 25, 2020
    Posts:
    5
    Thanks Ciaran,

    I was able to create a Prefab of the body proxy for each model and load them in the scene whenever needed, it works perfectly however the scene must start with at least one body proxy then I can disable/enable whenever needed.
     
  4. gjarnos

    gjarnos

    Joined:
    Jan 23, 2021
    Posts:
    3
    @CiaranWills What is the best practice for activating/deactivating a model? Currently we have a tracking screen for face tracking and we overlay a model/proxy by using model.SetActive(true) and when we exit the tracking screen we model.SetActive(false). All the same scene, not switching. When we reenter the tracking screen we seem to lose the model in the scene as all the children are deactivated and Mars won't turn them back on and we can't see the model until we SetActive(true) to a completely separate model. How should we sleep or deactivate a model with Mars in the correct way as to have it activate when we need it and have it off when we want it off?
     
  5. unity_QE9qONiuaZjjDg

    unity_QE9qONiuaZjjDg

    Joined:
    Mar 25, 2020
    Posts:
    5
    @gjarnos Since you can't activate the object again after you SetActive(False), I took two approached and works fine for me.
    1.Use DESTORY object instead of SetActive(False), then Instantiate the object again when needed.
    2. disable the Rendered of the object and all it's children then enable it again when needed sample code below
    Code (CSharp):
    1. Renderer[] r1 = models.transform.GetChild(productIndex).transform.GetComponentsInChildren<Renderer>();
    2.             for (int i = 0; i < r1.Length; i++)
    3.             {
    4.                 r1[i].enabled = false;
    5.             }
     
    CiaranWills likes this.