Team Spawn Grouping

Nikot93

New member
Hi,


I created a waiting room where the players are divided into two different teams, now I would like the two teams to appear in two different points of my map, but I probably did something wrong because in this way the spawn group is changed but the players of team 1 are not in the same scene as team 2.

C#:
namespace Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Game
{
    using Photon.Realtime;
    using Photon.Pun;
    using UnityEngine;
    using Opsive.Shared.Events;
    using Hashtable = ExitGames.Client.Photon.Hashtable;
    using Opsive.UltimateCharacterController.Game;

    public class CharacterSpawnManager : SpawnManagerBase
    {
        [SerializeField] protected GameObject[] m_Characters;

        public int SpawnGroupingTeam
        {
            get { return SpawnPointGrouping; }
            set { SpawnPointGrouping = value; }
        }


        void OnEnable()
        {
            Team t = PhotonNetwork.LocalPlayer.GetPlayerTeam();

            if (t == Team.Team1)
            {
                Debug.Log("team 1");
                SpawnPointGrouping = 1;
                Debug.Log("group: " + SpawnPointGrouping);

            }
            else if (t == Team.Team2)
            {
                Debug.Log("team 2");
                SpawnPointGrouping = 0;
                Debug.Log("group: " + SpawnPointGrouping);
            }
        }

        protected override GameObject GetCharacterPrefab(Player newPlayer)
        {
            if (newPlayer.CustomProperties.ContainsKey("ID"))
            {
                int result = (int)newPlayer.CustomProperties["ID"];
                Debug.Log("Character ID : " + result);
                return m_Characters[result];
            }
            else
            {
                return m_Characters[0];
            }

        }

    }
}
 
Is SpawnPointGrouping a property? What does it do? You likely need to make sure you set the grouping on the Respawner component.
 
Is SpawnPointGrouping a property? What does it do? You likely need to make sure you set the grouping on the Respawner component.
I'm sorry I solved, I put the correct code in case someone needs it

C#:
namespace Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Game
{
    using Photon.Realtime;
    using Photon.Pun;
    using UnityEngine;
    using Opsive.Shared.Events;
    using Hashtable = ExitGames.Client.Photon.Hashtable;
    using Opsive.UltimateCharacterController.Game;

    public class CharacterSpawnManager : SpawnManagerBase
    {
        [SerializeField] protected GameObject[] m_Characters;

        public override void OnEnable()
        {
            base.OnEnable();
            Team t = PhotonNetwork.LocalPlayer.GetPlayerTeam();

            if (t == Team.Team1)
            {
                SpawnPointGrouping = 1;
                Debug.Log("team 1 group: " + SpawnPointGrouping);

            }
            else if (t == Team.Team2)
            {
                SpawnPointGrouping = 0;
                Debug.Log("team 2 group: " + SpawnPointGrouping);
            }
        }

        protected override GameObject GetCharacterPrefab(Player newPlayer)
        {
            if (newPlayer.CustomProperties.ContainsKey("ID"))
            {
                int result = (int)newPlayer.CustomProperties["ID"];
                Debug.Log("Character ID : " + result);
                return m_Characters[result];
            }
            else
            {
                return m_Characters[0];
            }

        }

    }
}

Thank you
 
Top