Hello, I’m reworking my way through the RPG Core Combat course but modifying it as I go along to make a game more akin to the original Battleheart (most pertinently here is it uses a stage select system rather than a traversable path between different screens and the player can (optionally) control multiple characters).
For the MVP version, I have each stage (separate scenes) pre-seeded with one or more player character prefabs and an enemy spawner that spawns pre-defined waves of enemies. This works fine if I play each scene from within the scene itself, but I have just hooked up the stage select screen and am encountering a problem:
When I load into a new stage scene from the stage select, the pre-seeded player prefab(s) as well as the instantiated enemy prefabs are not spawning their Weapon gameobjects. I’ve been able to verify that the weapon Spawn method is running, but the weapon prefab is reading as null. Looking at the player and enemy gameobjects in the inspector, I can also see that their weapon prefab in the Fighter class is null as well.
So to restate, if I play the scene from within the scene normally, all of the weapon prefabs are showing up normally and instantiated enemies are also spawning their weapons, but if I enter the scene through LoadScene(), the character prefabs already in the scene as well as the instantiated enemy prefabs are listing their weapon prefab in Fighter.cs as null and therefore not spawning any weapon.
I’m wondering what I can do to begin investigating this? I’m not sure where the error might be since it seems to be happening between scene loads and everything else is working fine. I can post screenshots and script snippets later if necessary, but right now I’m more interested in what parts of the code or scene loading/unloading process I can investigate or research further to help me find the error myself.
Thanks a lot!