Multi Character Selection issue

nathanj

Active member
Hi Justin,

I'm having an issue with setting up a multi character selection. What's happening is when the second character enters the room they and the master client character work on in their view, but the second character is not updated in the master client's view. They have been instantiated but they are not recieving any updates.

I have the spawn point slightly above the terrain and in the Master client view the second player doesn't even fall, they are stuck in the air, while on their client view they are moving around fine.

I should add that do I have the character prefabs added to the Pun Object Pool Spawnable Prefabs list.

Any suggestions of what could be causing this? I've been on this for a while and am at a complete loss. Thanks in advance, Nathan

Code:
[SerializeField] protected GameObject m_Character;
        [SerializeField] protected GameObject[] characterArray;
       // [SerializeField] protected GameObject m_CustomCharacter;
        public GameObject Character { get { return m_Character; } set { m_Character = value; } }
       
        /// <summary>
        /// Abstract method that 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)
        {
            if (newPlayer.CustomProperties != null)
            {
             
                var character = newPlayer.CustomProperties["Character"];
                for (int i = 0; i < characterArray.Length; i++)
                {
                    string tempName = characterArray[i].name;
                    if (tempName.Equals(character))
                    {
                        print(tempName + "has entered the secene");
                        m_Character = characterArray[i];
                    }
                }
            }
            return m_Character;
        }
 
Last edited:
Check this thread out: (scroll about half way down)
 
Ok, so I created a new project, installed UCC, Pun, Pun Addon and then added the above script and everything worked as expected.

So, there is something obviously wrong within my build.

I’ll test this further and report back. Thanks again
 
So, it seems that all of my weird behaviours with builds relate to Opsive Pun converted prefabs somewhat corrupting durring the 2018.4 to 2019.3.6 upgrade - at least my characters.

As you know by now I'm not much for reading code on anything substantive level so all I can provide is vague interpretation.

My recent issue was having the Master client see or interact with subsequent clients. What ended up working was running the Character prefabs through the Opsive Pun converter again.

I know this sounds ridiculous but I tried it in three iterations of the project and this fixed every project. I don't know what happened to the prefabs because all of the components were on the characters - though two were replaced for somereason.

Anyways, incase anyone is having weird issues with builds where players are not instantiated correctly try converting your character prefabs again.

Nathan
 
Yes I did get it working; sorry I didn't see these replies earlier. You will add the character prefabs to the character spawn script. Modify a few of Justins scripts in order to get a default and custom character and then repeat for as many characters as you need!

Now the way I have mine scripted is you select your character by buttons; that button saves a custom property with which character you select. That custom property is then loaded on the scene load in the singlecharacterspawner and you're off and playing! My way might not be the way you need in your game but I will gladly help if needed!
 
Thanks again Arachai!

I got this sorted, what was actually happening was that my character prefabs needed to be converted through the Opsive Pun wizards. I'm not sure what happened but something had become corrupted in the files and was preventing them from loading properly in build with the multicharacter selection.
 
Top