Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Customization of companions or ennemies with asset bundles

Discussion in 'Prefabs' started by KCharlier, Feb 25, 2020.

  1. KCharlier

    KCharlier

    Joined:
    Nov 24, 2018
    Posts:
    5
    We scan and modelize real peoples from our school.
    Than, we use invector adon for mobile and create litle easy levels. The fun come from the fact that they knows one another in real world.

    In this video, there is a working sample.


    All the characters team (as companions or ennemies) should be choose from a menu list.


    From the editor, all is correct. In the screen captureyou can see that we have just put a prefab of the customized player. which contains the mesh and the rig. Then we change the avatar of the invector vThirdPersonMelee and IT WORKS !!




    BUT,
    BUT,
    BUT.......

    When we try to make the same by instantiating the prefab from an asset, he desperately stay in the T-POSE. And we give the good avatar from editor. we'll have to retrieve the avatar name from the bundle too... :-(





    public class santonsLoader : MonoBehaviour
    {
    public string bundleURL;

    public Transform spawnLocation;
    private GameObject newPrefab;

    public GameObject vThirdPerson;


    AssetBundle bundle;

    // initialisation
    IEnumerator Start()
    {
    WWW www = new WWW(bundleURL);
    yield return www;
    if (www.error != null)
    {
    throw new System.Exception("Tere is an error :" + www.error);
    }
    bundle = www.assetBundle;
    }
    public void Spawn(string assetName)
    {
    if (assetName == "")
    {
    Instantiate(bundle.mainAsset);
    }
    else
    {
    // Instantiate(bundle.LoadAsset(assetName));
    newPrefab = Instantiate(bundle.LoadAsset(assetName), new Vector3(0, 0, 0), Quaternion.identity) as GameObject;

    newPrefab.transform.SetParent(spawnLocation.transform);
    newPrefab.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
    }
    }


    Any help would be greatly appreciated.
    Thanks in advance.

    Klaude.
     
  2. KCharlier

    KCharlier

    Joined:
    Nov 24, 2018
    Posts:
    5
    Here are the screen captures, sorry it was thumbnails in the original post