Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

error while trying to set avatar for rig

Discussion in 'Editor & General Support' started by LetsMakeSomeGame, Dec 19, 2021.

  1. LetsMakeSomeGame

    LetsMakeSomeGame

    Joined:
    Jun 5, 2020
    Posts:
    11
    I made a humanoid avatar from a rig and duplicated that with ctrl + d after that when i tried to convert another one generic rig to humanoid rig with that duplicated avatar unity showed this error
    NullReferenceException: Object reference not set to an instance of an object
    It does not matter if I use drag and drop or select from the menu, the result is the same
    when i do this with first created avatar works find but when i trying use duplicated avatar this unity will throw this error
    Unity version : 2021.2.0f1
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,031
    The answer is always the same... ALWAYS. It is the single most common error ever.

    Don't waste your life spinning around and round on this error. Instead, learn how to fix it fast... it's EASY!!

    Some notes on how to fix a NullReferenceException error in Unity3D
    - also known as: Unassigned Reference Exception
    - also known as: Missing Reference Exception
    - also known as: Object reference not set to an instance of an object

    http://plbm.com/?p=221

    The basic steps outlined above are:
    - Identify what is null
    - Identify why it is null
    - Fix that.

    Expect to see this error a LOT. It's easily the most common thing to do when working. Learn how to fix it rapidly. It's easy. See the above link for more tips.

    You need to figure out HOW that variable is supposed to get its initial value. There are many ways in Unity. In order of likelihood, it might be ONE of the following:

    - drag it in using the inspector
    - code inside this script initializes it
    - some OTHER external code initializes it
    - ? something else?

    This is the kind of mindset and thinking process you need to bring to this problem:

    https://forum.unity.com/threads/why-do-my-music-ignore-the-sliders.993849/#post-6453695

    Step by step, break it down, find the problem.

    Here is a clean analogy of the actual underlying problem of a null reference exception:

    https://forum.unity.com/threads/nul...n-instance-of-an-object.1108865/#post-7137032
     
    LetsMakeSomeGame likes this.
  3. LetsMakeSomeGame

    LetsMakeSomeGame

    Joined:
    Jun 5, 2020
    Posts:
    11
    thanks, but this error throwed by unity editor and not relevant to my scripts
    basically, I have not written a single line of code yet and I am preparing the character to start the project
    its more like a bug in unity editor
    i just reporting this bug here and I'm not in trouble for this bug
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,031
    Would have been awesome if you mentioned that.

    Posting on a random forum about a Unity bug is a complete and total waste of time.

    Make a small project that shows the problem and go up to the Help button in Unity and file an actual bug if you're interested in getting it fixed.
     
    LetsMakeSomeGame likes this.
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @amirhoseinadlfar What asset are you using for your avatar? Perhaps VRChat? This does not sound like a built-in Unity component.
     
  6. LetsMakeSomeGame

    LetsMakeSomeGame

    Joined:
    Jun 5, 2020
    Posts:
    11
    sorry its was my first time posting in forum.unity.com
    I tagged this thread with bug i thought that was enough
    i will do this thank you
     
    Kurt-Dekker likes this.
  7. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @amirhoseinadlfar Before you create a test project, are you able to answer my question? If this is indeed VRChat or another separate asset, you would need to contact their support.
     
  8. LetsMakeSomeGame

    LetsMakeSomeGame

    Joined:
    Jun 5, 2020
    Posts:
    11
    i using mixamo characters
    upload_2021-12-20_20-51-56.png
    here i have a humanoid avatar
    upload_2021-12-20_20-53-25.png
    here i can chose the avatar as avatar source without any problem
    when i duplicate heraklios_a_dizonAvatar and trying to use duplicated avatar as avatar source unity shows this error
    NullReferenceException: Object reference not set to an instance of an object

    upload_2021-12-20_21-3-35.png
    upload_2021-12-20_21-14-28.gif
     

    Attached Files:

    Kurt-Dekker likes this.
  9. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @amirhoseinadlfar Got it! Yes, you would want to contact Mixamo, the error looks to be coming from their package. I went to their website but didn't immediately spot a support link, looks like you need to have a login.
     
  10. WoodsFiend

    WoodsFiend

    Joined:
    Oct 2, 2017
    Posts:
    10
    Ran into the same issue, it's not a mixamo issue, its the avatar copy from other avatar function. I suspect that the importer uses the avatar to find the rig transforms, when you duplicate the avatar and it has no parent model, you will notice you can no longer configure it. This is because it has lost reference to all the bone transforms (though in the file the bone names are all fine).

    I would say Unity should fix two things here:
    1. The copy from other avatar function in the importer just uses bone names and has no need for the transforms of the rig. This would allow those duplicated avatars to work.
    2. For further ease of use, Avatars can be setup with bone names instead of need to assign transforms. I should be able to create and configure an avatar using string names of bones only. (maybe make this optional as the transform assignment is good if you have no idea what you are doing)

    I create a solution to generate humanoid avatars at runtime for GLB models. The problem, I can't easily define an avatar and save it in my project so that I am able to import animations that match this avatar definition.
     
    calpolican likes this.
  11. calpolican

    calpolican

    Joined:
    Feb 2, 2015
    Posts:
    427
    Thanks for the info. Sorry to necro, but I also need to solve this issue, and this discussion has some valuable info available. Is there any workaround that we can use to have variants of an avatar that we can configure without just duplicating the model?