Sprite appearing in scene but not in game

Hey! I am working on this game, where the player travels between rooms and I’ve come across a problem.
After re-enabling the sprites (for performance reasons) only the tree sprites appear.
The ground doesn’t.
But when I check the scene view it shows that they’re there.
Heres a video of my problem.

Heres the script for both teleporters:

using Cinemachine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class teleportation : MonoBehaviour
{

    public Transform tp;
    public Transform player;

    public GameObject cam1;
    public GameObject cam2;
    public GameObject fadeEffect;
    public Canvas joystick;
    public GameObject tiles;
    public GameObject enableTiles;
    // Start is called before the first frame update
    void Start()
    {
       
    }

    // Update is called once per frame
    void Update()
    {
       
    }


    public void joystickopen()
    {
        joystick.enabled = true;
        fadeEffect.SetActive(false);
    }

    public void tping()
    {
       
        player.transform.position = tp.transform.position;

        cam1.GetComponent<CinemachineVirtualCamera>().enabled = false;
        cam2.GetComponent<CinemachineVirtualCamera>().enabled = true;
        tiles.SetActive(false);
        enableTiles.SetActive(true);
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "player")
        {

            joystick.enabled = false;
            fadeEffect.SetActive(true);
            Invoke(nameof(tping), 0.5f);
            Invoke(nameof(joystickopen), 0.5f);


        }
    }
}

Hi! Hard to tell from the code and video. It appears like the Z position of your camera changes from -10 to something like -960 after reentering the first scene. A camera position like that could very well be the cause for the ground being invisible in game-view only, as this only affects game view and not scene view. Maybe check that?

Oh yeah that seems to be the problem.
I just can’t figure out why the Z axis is changing when I go back to the first room.
And I tried to change the camera’s Z axis to something like -10 but it didn’t let me.
Could you suggest a fix?

1 Like

I found the problem.
The object where the player was teleporting to had a z value of -680.

I just changed the Z value to 0 and it fixed the problem.
Thank you for noticing the skewed z value:p

1 Like