Need help with my code

Hi I am creating a 2D platformer and I coded when fall to a certain point respawn to the start of the level, but when it teleports to the start the player goes invisible and doesn’t show up in the game but when I press the keys to go forward and jump the camera follows the invisible player
. Can you please help me figure out what it is

This is the code for when hitting a certain point teleport back to the start

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

public class KillPlayer : MonoBehaviour
{
public Transform spawnPoint;

void OnCollisionEnter2D(Collision2D col)
{
if (col.transform.CompareTag(“Player”))
col.transform.position = spawnPoint.position;
}

}

you need to change the position of the camera aswell when you teleport the player

Please use code tags when posting code
Even for little scripts it is still a lot more readable that way and it only takes a few seconds.
People may be more willing to help as well in return :wink:

https://discussions.unity.com/t/481379

What is the hierarchy setup of your player?
Is the camera attached to your player or is it separate and following the player?
Is your player Sprite (since you’re using 2D colliders) your Player object? or is it a separate child? Or maybe a different Game Object?
Are you sure you’re moving the right Game Object even though it has been tagged as “Player”?
Could you provide more information, others aren’t inside your project and don’t know what it looks like how things are set up. So it is difficult to determine when you’ve only given a small script that sets a position of a GameObject with only the explaination that it doesn’t do what you want it to do. Your environment is important to mention in this case

you need to try the OnCollisionExit2D method for changing position.