Exemplo n.º 1
0
        private void SpawnRemotePlayer(string name = null)
        {
            if (descriptor_ == null)
            {
                Debug.LogError("Cannot spawn player if there is no world descriptor!");
                return;
            }

            GameObject player = new GameObject("Remote Player");

            player.transform.parent = transform;
            player.layer            = LayerMask.NameToLayer("Player");
            // TODO do this better
            Transform spawn = GetSpawnPoint();

            player.transform.position = spawn.position;
            player.transform.rotation = Quaternion.Euler(0, spawn.rotation.eulerAngles.y, 0);

            GameObject playerVis = GameObject.CreatePrimitive(PrimitiveType.Sphere);

            playerVis.layer = player.layer;
            playerVis.transform.SetParent(player.transform, false);

            CyanEmuPlayer playerObj = player.AddComponent <CyanEmuPlayer>();
            VRCPlayerApi  playerAPI = CyanEmuPlayerManager.CreateNewPlayer(false, player, name);

            playerObj.SetPlayer(playerAPI);
            player.name = $"[{playerAPI.playerId}] {player.name}";
        }
Exemplo n.º 2
0
        private void SpawnLocalPlayer()
        {
            if (descriptor_ == null)
            {
                Debug.LogError("Cannot spawn player if there is no world descriptor!");
                return;
            }

            GameObject player = new GameObject("Local Player");

            player.transform.parent = transform;

            // Force move the player initially to the spawn point to prevent enter triggers at the origin
            Transform spawn = GetSpawnPoint();

            player.transform.position = spawn.position;
            player.transform.rotation = Quaternion.Euler(0, spawn.rotation.eulerAngles.y, 0);

            playerController_ = player.AddComponent <CyanEmuPlayerController>();
            playerController_.Teleport(spawn, false);

            CyanEmuPlayer playerObj = player.AddComponent <CyanEmuPlayer>();
            VRCPlayerApi  playerAPI = CyanEmuPlayerManager.CreateNewPlayer(true, player, settings_.customLocalPlayerName);

            playerObj.SetPlayer(playerAPI);
            player.name = $"[{playerAPI.playerId}] {player.name}";
        }
Exemplo n.º 3
0
        public static VRCPlayerApi GetPlayerByGameObject(GameObject obj)
        {
            CyanEmuPlayer player = obj.GetComponentInParent <CyanEmuPlayer>();

            if (player != null)
            {
                return(player.player);
            }
            return(null);
        }
Exemplo n.º 4
0
 public void SetPlayer(CyanEmuPlayer player)
 {
     player_ = player;
 }