5 using System.Collections.Generic;
27 private Dictionary<long, RemoteHeadInfo> remoteHeads =
new Dictionary<long, RemoteHeadInfo>();
44 private void Connected(
object sender = null, EventArgs e = null)
58 Vector3 headPosition = transform.InverseTransformPoint(headTransform.position);
59 Quaternion headRotation = Quaternion.Inverse(transform.rotation) * headTransform.rotation;
82 private void UserLeftSession(
User user)
84 int userId = user.
GetID();
87 RemoveRemoteHead(remoteHeads[userId].HeadObject);
88 remoteHeads.Remove(userId);
96 private void UserJoinedSession(
User user)
100 GetRemoteHeadInfo(user.
GetID());
114 if (!remoteHeads.TryGetValue(userId, out headInfo))
117 headInfo.UserID = userId;
118 headInfo.HeadObject = CreateRemoteHead();
120 remoteHeads.Add(userId, headInfo);
140 headInfo.
HeadObject.transform.localPosition = headPos;
141 headInfo.
HeadObject.transform.localRotation = headRot;
148 private GameObject CreateRemoteHead()
150 GameObject newHeadObj = GameObject.CreatePrimitive(PrimitiveType.Cube);
151 newHeadObj.transform.parent = gameObject.transform;
152 newHeadObj.transform.localScale = Vector3.one * 0.2f;
161 private void RemoveRemoteHead(GameObject remoteHeadObject)
163 DestroyImmediate(remoteHeadObject);