Why is the startpoint not being set On trigger enter? ((OnTriggerEnter2D(Collider2D other)),How do i get this to set a string on touch?

So i have this array of scripts set up where it functions as a way to put me outside of the room i enter when i load a new scene, so if i go through door 1, i will come out on the other side of door 1, and not in the middle of the scene or wherever i put my player.

I have the following strings setup:

  • startPoint - where the player will start
  • exitPoint - What it will set the player’s startpoint as in the next scene
  • PointName - the name of the point

The problem is that when I trigger the loadnewscene script it doesn’t change my startpoint. When i go into the new scene the field is empty. It works when i manually set it, but of course that isnt going to happen. I’ve attached the script in which lies the problem. Any help would be appreciated

When the new scene is loaded, the instance of this script is destroyed, as well as the player. Because of this, the player’s start point, though it was set before the scene was loaded, was reset to empty when the scene was loaded and a new player was created. To solve this, you’ll have to store the start point in something that doesn’t get destroyed between scenes, like a Singleton, and after the scene is loaded access the player and assign the start point.

Hope this helps!