Search Unity

Player appears behind tilemap after coming from another scene HELP!

Discussion in 'Getting Started' started by MArafatHossain, Feb 15, 2020.

  1. MArafatHossain

    MArafatHossain

    Joined:
    Jan 26, 2020
    Posts:
    7
    I'm in the scene "Scene 1" and I make the player trigger a box collider 2D and which takes the player to another scene ie. "Scene 2" (the player is Dontdestroyonload-ed). The player appears behind the tilemap (background) when I want it to be shown in front. I can move the player around and I know the player is there in the scene as the camera follows the player around when I use the WASD keys. It works fine in 12 other scenes except for this one scene I am working on and I have no Idea why. Everything (settings) are the same and nothing is changed. In the Grid>Tilemap>Tilemap Renderer>Additional Settings>Sorting Layer: Background, whereas the player is in front in the sorting layer. (As it is and works in the 12 other scenes). When I run the game from the scene "Map 2" (which is showing this problem) the player appears on top of the tilemap fine but it is not the same when the player comes from another scene.

    Help me out guys I really need welp!


    Edit #1: I see that in the scene tab the player shows up when I press play but in the Game tab the player is not visible.

    Edit #2: I managed to resume with my project by deleting the entire scene and copy pasting the needed components from one of the other scenes and it works (ie. the player shows above the tileset) - Note: This is not a fix.. I cheated cause I just wanted to continue working with my project. I would really like to know how to fix this issue in the future if it ever pops up.

    Edit #3: Every scene I make now makes the player invisible (not visible.. maybe the player is there on top but not showing when I come from another scene. I am forced to copy and paste stuff from previous working scenes to resume with my work. Please help solve this issue. I feel like I'm now working on a broken project.
     
    Last edited: Feb 15, 2020
  2. MArafatHossain

    MArafatHossain

    Joined:
    Jan 26, 2020
    Posts:
    7
    Ayy managed to solve it! Just made all the Entrances, Exits have Z-axis are above the camera Z axis. (I'm making a 2D game so every entrance and exit for me was 0 whilst the camera Z-axis is set at -10) Have no clue why that helped but it did.

    Happy game deving! <3
     
  3. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,203
    Unity's 2D isn't actually 2D. It's 3D with the camera set up to make everything seem 2D. If you click the "2D" button on the Scene view and then move the camera around you can see the actual 3D objects making up your sprites. When you alter the Z axis for a sprite you are moving it in 3D space even if it doesn't look like it in 2D camera mode.

    Below are example screenshots of the Unity 2D Game Kit in 2D camera mode and in 3D scene view.

    upload_2020-2-16_1-28-16.png

    upload_2020-2-16_1-30-15.png
     
    Last edited: Feb 16, 2020