Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Player Object not showing in build of game

Discussion in '2D' started by Jordanperkins98, Jul 27, 2021.

  1. Jordanperkins98

    Jordanperkins98

    Joined:
    Mar 31, 2020
    Posts:
    7
    The player shows up and works fine in the editor, however when I make a build the player does not show up, I have hidden all background images and it still does not show up, he is sat on z-axis of 0 and is in a sorting layer, however, I don't think it's a camera issue as i don't think the game object is in the game or not as no sound effects are being played.



    I really don't know how to fix this issue as i cant even figure out why its doing it, does anyone have any idea?
     
  2. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    1,353
    Try creating a brand new scene, throwing the player in it and building it that way. See if it shows then.
     
  3. Jordanperkins98

    Jordanperkins98

    Joined:
    Mar 31, 2020
    Posts:
    7
    Yes it did appear, so does that mean it is a problem with the camera?
     
  4. Jordanperkins98

    Jordanperkins98

    Joined:
    Mar 31, 2020
    Posts:
    7
    So i make a new scene and i attach my script and it now doesn't appear not sure what could be causing it to do that when the game builds
     
  5. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    1,353
    Can you share the script (Use code tags pleeeasssee)
     
  6. Jordanperkins98

    Jordanperkins98

    Joined:
    Mar 31, 2020
    Posts:
    7
    Hi, I've done some more digging, I made a new game file completely and I can replicate the issue just by adding a Rigidbody2D to a sprite, it disappears when I build the game but not in-game view, no code attached.
     
  7. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    1,353
    So small question but big implications: Do you have a floor or platform for the player to land on? I just wonder if the by the time it loads on your build that the player is technically still there but is just falling down and out of the camera's view. You can try turning off gravity on the Rigidbody2D to test that out (if you dont have a floor with a boxcollider2D to land on). Make sure to add a collider2D of some kind to the sprite with the rigidbody.

    If yes, that is incredibly bizarre and a bug. Try using a different version of Unity. You can also share your inspector from when clicked on the player showing all the components and their settings, try that before re-installing.
     
  8. Jordanperkins98

    Jordanperkins98

    Joined:
    Mar 31, 2020
    Posts:
    7
    Yep thats it, by the time the game loads the player falls, at least i have figured out whats happening now.

    but not sure how to solve the problem, would i have to hold the player there for 5 seconds or x amount of time. or is there a better way? this is Unity 2020.3.9 so surely it cant be the version causing that?
    upload_2021-7-27_20-3-38.png upload_2021-7-27_20-3-50.png
     
  9. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    1,353
    Just changing the gravity scale to 0 should have done the trick. However, if you dont change the gravity scale to 0 it should fall. If you place a floor that has a collider2D it shouldnt fall through it will just fall onto it.