Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question Player Invisible on Build

Discussion in 'General Graphics' started by Faemoose, Aug 23, 2023.

  1. Faemoose

    Faemoose

    Joined:
    Aug 23, 2023
    Posts:
    4
    This is a simple 3D game and I'm trying to build it for Windows with Mono backend scripting. However when I run the build, the player object cannot be seen. I know it's still there because the game functions properly (e.g. falling objects disappear on impact with player and score is updated) but player is just not visible. Others in the forums who have had this problem reported inactive meshes or incorrect shaders; I have tried a few of those methods but I must be missing something because it still doesn't work.

    To explain the attached screenshots, I was taught to make a primitive player object first (in this case a sphere, seen in pic1) for simplicity of early development. Then later I attached my actual desired asset (pic2) as its child - in this case, it is a person with multiple skins available, so the "Person" object doesn't have a mesh but the chosen skin does (pic3).

    EDIT: I realized something I hadn't tried: I gave my primitive parent object (the sphere) a material to make it visible, and when I did that I could see the sphere in a build, but still not the person. Does anyone know why it only shows the topmost parent object and none of the children?

    player inspector 1.PNG

    player inspector 2.PNG

    player inspector 3.PNG

    I would greatly appreciate any help with this :)
     
    Last edited: Aug 23, 2023
  2. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    1,042
    Is the player character being spawned in after the scene is loaded? If so, it is likely that the shaders used by the object are being stripped because nothing is directly referencing them. As a test, try putting a copy of the player character in the scene somewhere and make a build. If the player becomes visible then you'll know that's what is going on.
     
  3. warthos3399

    warthos3399

    Joined:
    May 11, 2019
    Posts:
    1,804
    Nice catch Sluggy, only other thing ive seen cause this is OC. If your using occlusion culling and the character is tagged as OC, it will do the same thing sometimes.
     
    Sluggy likes this.
  4. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    1,042
    Only reason I even considered it was because it happened to me just yesterday when I was using some proc-gen terrain which would become invisible in the build. Turns out the shader I was using (it's from FlatKit) doesn't play well with URP due to the number of variants it can produce - attempting to put it in the 'Always include shaders' section was causing something in the order of 1.2 billion different shaders to compile and be included! Even though the material using it *was* referenced by the component that generates the terrain it still seems to not have worked. My only guess is that Unity couldn't figure out which variants to strip from that reference alone? So I ended up having to use a terrain with the given shader in a dummy scene to force Unity to know it was being referenced and now it only produces 250 different variants... only one of which do I actually even use :rolleyes:

    I hadn't even considered the occlusion system since I never used it. That's a good idea to check too.
     
    warthos3399 likes this.
  5. warthos3399

    warthos3399

    Joined:
    May 11, 2019
    Posts:
    1,804
    250 variants is way too high. I had a project a few years ago, where testers were unable to see the main character at certain angles (invisible). Checked the asset, and it was marked for OC in tags. Corrected, bug fixed. Only had to re-bake OC...