public OnlineBody(string aName) { parts = new BodyPart[25]; string bodypartlist = "FootLeft,AnkleLeft,KneeLeft,HipLeft,FootRight,AnkleRight,KneeRight,HipRight,HandTipLeft,ThumbLeft,HandLeft,WristLeft,ElbowLeft,ShoulderLeft,HandTipRight,ThumbRight,HandRight,WristRight,ElbowRight,ShoulderRight,SpineBase,SpineMid,SpineShoulder,Neck,Head"; string[] bodypartarray; bodypartarray = bodypartlist.Split("," [0]); name = aName; go = new GameObject("OnlineBody:" + name); go.transform.position = KinectWorld.s.transform.position; go.transform.parent = OnlineBodyView.s.transform; partsDic = new Dictionary <string, BodyPart> (); //height.transform.parent = go.transform; GameObject height = new GameObject("Height:" + name); OnlineBodyHeight h = height.AddComponent <OnlineBodyHeight> (); for (int i = 0; i < bodypartarray.Length; i++) { parts[i] = new BodyPart(bodypartarray[i], go, this); partsDic.Add(parts[i].name, parts[i]); if (parts[i].name == "SpineBase") { h.bodyName = name; h.transform.position = parts[i].go.transform.position; h.spineBase = parts[i].go.transform; } } OnlineBodyPhysics phys = go.AddComponent <OnlineBodyPhysics> (); avatarScript = go.AddComponent <AvatarOnlineBody> (); avatarScript.body = this; phys.onlineBody = this; phys.heightSphere = h; //OnlineBodyView.s.maptokinect.AssignBody (name); }
public void DeleteBody(string name) { for (int i = 0; i < bodies.Length; i++) { if (bodies[i].name == name) { //Destroy(bodies[i].character.gameObject); OnlineBodyPhysics physScript = bodies[i].go.GetComponent <OnlineBodyPhysics>(); Destroy(physScript.heightSphere.gameObject); Destroy(bodies[i].go); bodies[i] = null; if (PlayerManager.s.currentPlayer != null && name == PlayerManager.s.currentPlayer.name) { PlayerManager.s.currentPlayer = null; } break; } } }