void Connect(string IP) { for (port = GyroMoteServer.startPort; port < (GyroMoteServer.startPort + GyroMoteServer.portRange); port++) { if (Network.Connect(IP, port, GyroMote.ConnectionString()) == NetworkConnectionError.NoError) { break; } } if (Network.peerType == NetworkPeerType.Client || Network.peerType == NetworkPeerType.Connecting) { Debug.Log("Connected to " + IP + ":" + port); } else { Debug.Log("unable to connect to " + IP + ":" + port); } }
void Update() { if (gyroBool || Application.isEditor) { #if UNITY_IPHONE quatMap = gyro.attitude; #endif #if UNITY_ANDROID if (gyro != null) { quatMap = new Quaternion(gyro.attitude.x, gyro.attitude.y, gyro.attitude.z, gyro.attitude.w); } #endif #if UNITY_EDITOR if (rGyro == null) { rGyro = GyroMote.gyro(); } if (rGyro != null && !started) { OnStartedGyro(); started = true; Debug.Log("Started"); } if (rGyro != null) { quatMap = rGyro.attitude; } else { } #endif transform.localRotation = quatMap * quatMult; m_GyroQuat = transform.rotation; m_GyroEuler = transform.eulerAngles; } }
// Update is called once per frame void Update() { if (SystemInfo.supportsGyroscope) { Vector3 position = new Vector3(gyroscope.gravity.x * -1, gyroscope.gravity.z, gyroscope.gravity.y); gravity.transform.position = position; } else { if (remoteGyroscope == null) { remoteGyroscope = GyroMote.gyro(); } if (remoteGyroscope) { gravity.transform.position = new Vector3(remoteGyroscope.gravity.x * -1, remoteGyroscope.gravity.z, remoteGyroscope.gravity.y); } } transform.LookAt(gravity); }
// Use this for initialization void Start() { gyroscope = GyroMote.gyro(); //gyroscope.attitude; }