I am having this bug where the state of the fighter is restored property on load (the correct last weapon is equipped) but when I save and load through the portal, it always changes the state to unarmed when I enter the next scene. I don’t know where this bug could be occuring (my thinking it either the Fighter.cs or Portal.cs). Any assistance would be much appreciated!
IEnumerator Transition()
{
if (sceneToLoad < 0)
{
Debug.LogError("Scene to load not set");
yield break;
}
DontDestroyOnLoad(gameObject);
Fader fader = FindObjectOfType<Fader>();
SavingWrapper wrapper = FindObjectOfType<SavingWrapper>();
PlayerController playerController = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>();
playerController.enabled = false;
yield return fader.FadeOut(fadeOutTime);
wrapper.Save();
yield return SceneManager.LoadSceneAsync(sceneToLoad);
PlayerController newPlayerController = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>();
newPlayerController.enabled = false;
wrapper.Load();
Portal otherPortal = GetOtherPortal();
UpdatePlayer(otherPortal);
wrapper.Save();
yield return new WaitForSeconds(fadeWaitTime);
fader.FadeIn(fadeInTime);
newPlayerController.enabled = true;
Destroy(gameObject);
}
Ive attached my Transition function in Portal in case there was something I was missing that could be causing the issue.