private void HandleInput() { if (Input.GetKey(KeyCode.Escape)) { #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; #else Application.Quit(); #endif } if (Input.GetKeyDown(KeyCode.Space)) { var oponent = oponents.GetOponent(0); Debug.Log("Id: " + oponent.Id); Debug.Log("TransCount: " + oponent.TransCount); for (int i = 0; i < oponent.TransCount; i++) { Trans t = oponent.GetTrans(i); Debug.Log(t.Id + " : " + t.Pos); } } if (inputController == null) { inputController = GameObject.FindObjectOfType <SteamVR_TrackedController>(); if (inputController != null) { inputController.TriggerClicked += OnTriggerClicked; } } }
private void ProcessOponents() { for (int i = 0; i < oponents.Count; i++) { Oponent oponent = oponents.GetOponent(i); if (oponent.TransCount > 0) { Trans t = oponent.GetTrans(0); GameObject obj = GameObject.Find("Client (" + oponent.Id + ")"); if (obj == null) { // Body controlled by keyboard if (oponent.TransCount == 1) { obj = Instantiate(Resources.Load("Avatar/AvatarNoCam")) as GameObject; } // Body controlled by VR sensors if (oponent.TransCount > 1) { obj = Instantiate(Resources.Load("Avatar/AvatarVRNoCam")) as GameObject; } obj.transform.parent = this.transform; obj.name = "Client (" + oponent.Id + ")"; } for (int j = 0; j < oponent.TransCount; j++) { t = oponent.GetTrans(j); Transform child = obj.transform.FindDeepChild(t.Id); if (child == null) { Debug.Log("Transform " + t.Id + " not found"); continue; } //Debug.Log("Transform: " + t.Id); child.position = t.Pos; child.rotation = t.Rot; } --oponent.TTL; if (oponent.TTL <= 0) { Destroy(obj); } } } for (int i = oponents.Count - 1; i >= 0; i--) { Oponent o = oponents.GetOponent(i); if (o.TTL < 0) { oponents.RemoveOponent(o.Id); } } }