I have this script that I used to toggle the player between one scene and another scene. The script works by calling a function when a certain button is pressed (this function switches the scenes). Take a look:
public class ToggleScript : MonoBehaviour
{
public Transform normalPlayer;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Q))
{
ReloadScene();
}
}
public void ReloadScene()
{
SceneManager.LoadScene("AltScene");
if (Input.GetKeyDown(KeyCode.E))
{
LoadOrigional();
}
}
public void LoadOrigional()
{
SceneManager.LoadScene("NormalScene");
}
}
When I run this script, I start in “NormalScene” (as that’s where the game starts). When I press Q, the game takes me to “AltScene” by calling the ReloadScene() function, but when I press E to take me back to “NormalScene” nothing happens. Can someone explain to me why this happens? On a side note, is there any way for me to make sure the player stays in the same positon (so if my player was at X-Coordinate 70 when I switch the scenes I want it to stay at X-Coordinate 70 when the scene is put on again. This issue is not the priority). Thank you so much for your help ![]()