Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// ---------------------------------------------
- /// Ultimate Character Controller
- /// Copyright (c) Opsive. All Rights Reserved.
- /// https://www.opsive.com
- /// ---------------------------------------------
- namespace Opsive.UltimateCharacterController.AddOns.Multiplayer.PhotonPun.Game
- {
- using UnityEngine;
- using Photon.Realtime;
- /// <summary>
- /// Manages multiple character instantiation within a PUN room.
- /// Add this script to the 'PhotonPUN\Scripts\Game' folder.
- /// 1) Open 'DemoRoom' scene
- /// 2) Find 'PunGame'
- /// 3) Replace SingplePlayerSpawnManager with this component.
- /// </summary>
- public class MultiplePrefabSpawnManager : SpawnManagerBase
- {
- [Tooltip("Index of the prefab array.")]
- [SerializeField] protected CharacterPrefabType m_CharacterType = CharacterPrefabType.Nolan;
- [Tooltip("A reference to the character that PUN should spawn. This character must be setup using the PUN Multiplayer Manager.")]
- [SerializeField] protected GameObject[] m_CharacterList;
- public enum CharacterPrefabType
- {
- Nolan = 0,
- RobotKyle = 1,
- }
- public CharacterPrefabType CharacterType { get { return m_CharacterType; } set { m_CharacterType = value; } }
- public GameObject Character { get { return m_CharacterList[(int)m_CharacterType]; } }
- /// <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)
- {
- // Return the same character for all instances.
- return Character;
- }
- public GameObject GetCharacterPrefab(Player newPlayer, CharacterPrefabType characterType)
- {
- m_CharacterType = characterType;
- return Character;
- }
- }
- }
Add Comment
Please, Sign In to add comment