#Issues with character selection mechanics

1 messages · Page 1 of 1 (latest)

void wasp
#

I have code for character selection, and for the Network Manager, the player prefab has a placeholder with Network Identity. Everything works, but the character is not controllable with the character selection code. However, without the character selection code, everything works.
I have a code that prevents camera duplication for both characters. However, when selecting a character, the camera turns off, and if I remove this code, the camera duplicates. I don't know how to fix it, and I've been struggling with this issue for three days already. Please help me.
if (!isLocalPlayer)
{
playerCamera.gameObject.SetActive(false);
}
If you need the code for character control and character selection, please provide it.The code was taken from https://youtu.be/33cAxBiFUTw.I just wanted to do something to play with my friends but didn't know it would get so complicated. + my knowledge in the mirror is not great

This Unity Multiplayer tutorial will teach you how to implement character selection in your project. For project files access, check out my GitHub here: https://github.com/DapperDino/Mirror-Multiplayer-Tutorials

Multiplayer Course: https:/...

▶ Play video
crystal dove
void wasp
# crystal dove How do you spawn characters after character selection

public class CharacterSelect : NetworkBehaviour
{
[SerializeField] private GameObject characterSelectDisplay = default;
[SerializeField] private Transform characterPreviewParent = default;
[SerializeField] private TMP_Text characterNameText = default;
[SerializeField] private float turnSpeed = 90f;
[SerializeField] private Character[] characters = default;

    private int currentCharacterIndex = 0;
    private List<GameObject> characterInstances = new List<GameObject>();

    public override void OnStartClient()
    {
        if (characterPreviewParent.childCount == 0)
        {
            foreach (var character in characters)
            {
                GameObject characterInstance =
                    Instantiate(character.CharacterPreviewPrefab, characterPreviewParent);

                characterInstance.SetActive(false);

                characterInstances.Add(characterInstance);
            }
        }

        characterInstances[currentCharacterIndex].SetActive(true);
        characterNameText.text = characters[currentCharacterIndex].CharacterName;

        characterSelectDisplay.SetActive(true);
    }

    private void Update()
    {
        characterPreviewParent.RotateAround(
            characterPreviewParent.position,
            characterPreviewParent.up,
            turnSpeed * Time.deltaTime);
    }

    public void Select()
    {
        CmdSelect(currentCharacterIndex);
        characterSelectDisplay.SetActive(false);
    }

    [Command(requiresAuthority = false)]
    public void CmdSelect(int characterIndex, NetworkConnectionToClient sender = null)
    {
        GameObject characterInstance = Instantiate(characters[characterIndex].GameplayCharacterPrefab);
        NetworkServer.Spawn(characterInstance, sender);
    }
brave summit
#

I would try doing this in the NetworkManager script

crystal dove
#

Call this method instead of NetworkServer.Spawn()

void wasp
#

thanks