Respawning after changing loadout problem


Author: Aaronn Solomon

12/13/2023

The Problem

I wanted to let the player change loadouts after death, and then spawn into the same level when they were ready. However, I kept running into a problem with the previous scene name variable I had. It would keep being reset as soon as I pressed the button to respawn, and I had to clue why.


The Solution

The variable I made was getting reset whenever a new scene loaded because it wasn't indestructible. Whenever a new scene was loaded, the variable was reset to its default. So, by simply moving the variable to my indestructible script, and then using it in my code for respawning, the variable stayed the same across all scenes.