예제 #1
0
        public async void OnGenerateAvatar(int id, AvatarTransform avatarTransform, byte[] avatarData)
        {
            var head      = new GameObject("head");
            var rightHand = new GameObject("rightHand");
            var leftHand  = new GameObject("leftHand");

            head.transform.SetPositionAndRotation(avatarTransform.Head.Position, avatarTransform.Head.Rotation);
            rightHand.transform.SetPositionAndRotation(avatarTransform.RightHand.Position, avatarTransform.RightHand.Rotation);
            leftHand.transform.SetPositionAndRotation(avatarTransform.LeftHand.Position, avatarTransform.LeftHand.Rotation);

            var avatar = new VRMAvatar(head, rightHand, leftHand);
            await avatar.GenerateAvatar(avatarData);

            head.transform.SetParent(avatar.Root.transform);
            rightHand.transform.SetParent(avatar.Root.transform);
            leftHand.transform.SetParent(avatar.Root.transform);

            var synchronizer = avatar.Root.AddComponent <AvatarSynchronizer>();

            synchronizer.SetTargets(avatar.Head, avatar.RightHand, avatar.LeftHand);

            var voiceChat = avatar.Root.AddComponent <VoiceChat>();

            playerSynchronizers[id] = synchronizer;
            playerAvatars[id]       = avatar;
            playerVoiceChats[id]    = voiceChat;
        }
예제 #2
0
파일: Client.cs 프로젝트: Ponsukeee/Vcom
        private void Awake()
        {
            Avatar     = new VRMAvatar(head, rightHand, leftHand);
            gameClient = new GameClient();

            restHN = restServerHostName;
            moHN   = moServerHostName;
        }
예제 #3
0
        public async Task GenerateAvatarForOthers(VRMAvatar avatar)
        {
            try
            {
                var avatarTransform = CreateAvatarTransform(avatar.Head.transform, avatar.RightHand.transform, avatar.LeftHand.transform);
                var roomPlayers     = await hub.GenerateAvatarAsync(avatarTransform, avatar.AvatarData);

                foreach (var playerInfo in roomPlayers)
                {
                    if (selfID != playerInfo.ID)
                    {
                        receiver.OnGenerateAvatar(playerInfo.ID, avatarTransform, playerInfo.AvatarData);
                    }
                }
            }
            catch (Exception e)
            {
                Notification.Notify("アバター生成に失敗しました");
                Debug.LogError(e);
                await LeaveAsync();

                throw;
            }
        }