cancel
Showing results for 
Search instead for 
Did you mean: 

OvrAvatar materials missing?

myBadStudios
Protege
I have wanted to see my custom avatar in my game since day one... Instead, whenever I turn on the ShowThirdPerson boolean I either see the default blue character or nothing at all but in both cases I get 999+ NullFerenceException errors and it turns out they are all related to trying to use the materials that are supposed to be in that prefab. 

The first two (Surface Shader and Surface Shader self Occluding) are set and the rest are empty. I get so much slack from that it's not even funny. So I eventually decided that I would manually fix up the prefab that Oculus included in the latest update for Unity. Apparently installing that package into a new project starts you off with a broken prefab? Huh? So which materials to use? I noticed that the first missing shader has PBS in it's name and all the rest have PBSV2 in it's name and so I dragged in AvatarSurfaceShaderPBS and AvatarSurfaceShaderPBSV2 respectively. 

This successfully removed all the NullReferenceException errors... and also now leaves me with no avatar. 

I recently read that the avatar now uses a string id instead of an unsigned int and yet all the documentation I can find on here and via Google all still say to copy the game id as the avatar id. Just today I was following a tutorial on how to properly load your custom avatar and copy pasted the code from here into my project. Before I changed the shaders I was getting those errors all the time but noticed that something was different with my avatar. It was still the generic head but it was now brown. Interesting.... Now that I have replaced the shaders it is missing completely...

By copy pasting the code that I got from the documentation, though, it gave me an error saying it can't convert the numeric value to a string like the avatar ID requires so I had to convert the ID to a string to make it compile. I now believe strongly that I am using the wrong value there but can't seem to find ANY documentation relating to where to get the string id of the avatar. So, by me loading the wrong avatar id, am I not receiving any avatar now? Or is it not showing because I picked wrong materials for the OvrAvatar component?

Should I go break each one of the materials one by one and replace it with one shader after another until I have tried all combinations of the 4 available shaders into each of the 5 available slots? That's what... 5 to the power of 4 is 625 possible combinations isn't it? And that is while using the app id as avatar id and not using the app id as avatar id so that gives me a total of 1250 possible combinations to try to get this avatar to show up.

That is just plan ridiculous. Can someone just tell me what materials are supposed to go into that broken LocalAvatar prefab, please? Also, where in the world can I get info on the new string id the avatar requires to load the correct avatar to try and show?

Thanks to anyone who can shed some light on this for me.
2 REPLIES 2

lsummers
Protege
Given your unique issues in your other thread related to the SDK, and that you are using Unity 2018 (which is bleeding edge in the Unity world, and they recently changed a whole ton of stuff to do with materials and shaders - including cautioning it would break some materials and shaders), I'd be highly suspect that either your SDK is out-of-date OR your Unity package isn't compatible / tested yet with the SDK

You can install multiple versions of Unity side-by-side on as system.  The more you work in XR, the more you'll want to start doing this. Xbox One, PS4, Nintendo, HTC Vive, Daydream, OVR - they all have "sweet" spots for Unity (and some only work on VERY specific versions).  Lots of VR systems are only compatible with 5.6.  A few more are compatible with 2017.  2018 is a complete random gamble and generally completely unsupported by anyone.  Being bleeding edge on the SDK and Unity means stuff will be tested less and broken more...

I always keep a Unity 5.1 installed (BB10 support).  5.6 installed (CAVE system, OVR support, Daydream support, Vive support - easily the most reliable).  2017 installed (but only used for clients who made the mistake of upgrading from 5.6).  And 2018 we don't use anywhere on our team.  It needs to mature first.  Also, depending on where you got your SDK's and assets from - keep in mind that the versions downloaded are at a "point in time".  So if you downloaded a 5.1 compatible asset, and open Unity 2017, the asset i has cached and downloaded is for 5.1 and won't work.

myBadStudios
Protege
Interesting read to be sure!

Since 2017 is so old already and 2018 has been out for a while now I was under the impression that nobody uses Unity5 any more. All my assets on the store require 2017.3 as minimum (but to be fair, that was because all my kits run off a central core and the core got broken in 2017.3 and needed to be completely rewritten, thus forcing the new minimum supported version).

Point is, I would have thought most people jump on bleeding edge as soon as it becomes available and soon Unity would release stats showing that 60% of ppl are on 2018, 35% are on 2017, 4% on 5 and 1% on "other". To hear you advocate Unity 5 was a definite surprise! I currently have 3 versions of Unity on my system. Why three? Because I removed Unity 5 just last month, that is why not 4 any more :expressionless:

Having said that, replacing all those shaders with the mobile version worked just fine. After I started messing around with the code to get my custom avatar into the scene and reading about how you say I should first call Initialise asynconiously and feed the resulting user id to my avatar BEFORE my avatar's Start function runs I discovered that I could programmatically also cause the issue by having an avatar in the scene and then loading my custom avatar while the avatar was already active in the scene. Instant missing reference exception errors galore. That I put down to my own fault though and I just updated my code to work the way you instructed.

Having said that, the code to load my custom avatar is in the bootstrap scene and I am working in the game scene most of the time so I needed a pre-loaded avatar in there and it simply wasn't working. Using the mobile shader fixed the issue and allowed me to see my avatar without any null reference exceptions.

As for the avatar id, turns out the numeric value jut had to be converted to a string and that loaded my avatar just fine. At least the mystery of why I couldn't find any info on the string id apart from "Depending on the version of the SDK you are using you might have to use a string instead of the unsigned int" was solved also. Would have saved me a lot of time and trouble if you could have just made it clear that the id didn't change at all and there was no new field for me to go look for in the project page, you simply require return an int and require a string so I just have to convert it and job's done.

In either event, stuff is working now so I duplicated the prefabs into my own folder so that future updates won't break the working prefabs. All good now! 🙂