Custom spawn managers not working

I can't get my custom spawn manager working. When I use it in the demo scene nothing spawns (none of the public gameobjects are null). What am I doing wrong?

using UnityEngine; using Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Game; using Photon.Realtime; public class MySpawnManager : SpawnManagerBase { public GameObject myGameObject; public GameObject myGhost; public GameObject myWallWalker; public GameObject myRocketJumper; /// <summary> /// Virtual method which allows for a character to be spawned based on the game logic. /// </summary> /// <param name="newPlayer">The player that entered the room.</param> /// <returns>The character prefab that should spawn.</returns> protected override GameObject GetCharacterPrefab(Player newPlayer) { Debug.Log("Spawning characters, newPlayer: " + newPlayer.TagObject); switch((int) newPlayer.TagObject){ case 1: return myGhost; break; case 2: return myWallWalker; break; case 3: return myRocketJumper; break; } return myGameObject; // Replace with your own game logic. } }
 
Is GetCharacterPrefab being called? Did make sure to add your component instead of the default component?
 
Is GetCharacterPrefab being called? Did make sure to add your component instead of the default component?
Yes to both, I've been trying to get it to work for days.

Steps to reproduce are simple:
1. Install the latest versions of Ultimate Character Controller and PUN Multiplayer Add-on.
2. Create a new C# script called MySpawnManager and copy and paste the above code into it.
3. Go to the DemoRoom scene and replace the Single Player Spawn Manager with MySpawnManager.
4. Configure MySpawnManagers' parameters to match the SinglePlayerSpawnManager parameters
5. Add the player prefabs to the MySpawnManager script.
6. Add the Menu and DemoRoom scenes to the build settings and run as normal.

Result: No player prefab spawns.
 
If GetCharacterPrefab is being called then your component is being called. Are you sure the correct prefab is being returned? You could set a breakpoint within GetCharacterPrefab and ensure the correct prefab is being returned. Immediately after that method is called there is a call to have PUN spawn the character so it should be easy to track.
 
If GetCharacterPrefab is being called then your component is being called. Are you sure the correct prefab is being returned? You could set a breakpoint within GetCharacterPrefab and ensure the correct prefab is being returned. Immediately after that method is called there is a call to have PUN spawn the character so it should be easy to track.
It is definitely the right character prefab. It works perfectly when using the Single Player Spawn Manager but falls apart whenever custom logic is added.
 
Because you are returning you don't need to break. But that's not going to fix it, I just made a quick test, with your code but without the breaks and formatted differently.

Helps to Provide The Log >
NullReferenceException: Object reference not set to an instance of an object
ChosenPlayerSpawner.GetCharacterPrefab (Photon.Realtime.Player newPlayer) (at Assets/FST_Scripts/Test/ChosenPlayerSpawner.cs:19)
Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Game.SpawnManagerBase.SpawnPlayer (Photon.Realtime.Player newPlayer) (at Assets/Opsive/UltimateCharacterController/Add-Ons/Multiplayer/PhotonPUN/Scripts/Game/SpawnManagerBase.cs:142)
Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Game.SpawnManagerBase.Start () (at Assets/Opsive/UltimateCharacterController/Add-Ons/Multiplayer/PhotonPUN/Scripts/Game/SpawnManagerBase.cs:95)

Logic used>
protected override GameObject GetCharacterPrefab(Player newPlayer)
{
Debug.Log("Spawning characters, newPlayer: " + newPlayer.TagObject);
return (int)newPlayer.TagObject switch
{
1 => myGhost,
2 => myWallWalker,
3 => myRocketJumper,
_ => myGameObject,
};
}
After a quick chase I think the TagObject is Null.

I hope this can be of some help, I will investigate further as I get the time.
 
After a quick chase I think the TagObject is Null.
In this demo scene it is meant to be null and should just result in the function returning the game object instead of the object listed in the switch. I'll add an explicit null check to ensure that isn't what's causing problems.

I appreciate all the help.
 
Top