my camera no longer displays my background

Viewed 21

so i wrote a sript that when my Player touches my enemy. my Player respawn should know that my camera is following my player. But when I respawn, she moves behind my background

how to do?

My scipt

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

public class Respawn : MonoBehaviour
{
    [SerializeField] Transform spawnPoint;
    void OnCollisionEnter2D(Collision2D col)
  {
    if (col.transform.CompareTag("Player"))
      col.transform.position = spawnPoint.position;

  }
}

//Thanks

1 Answers

There are two things you could do:

  1. Use z axis to place object (player) in front.
  2. Use sorting layers and sorting group component.
Related