// Update is called once per frame void Update() { GameObject g = GameObject.FindGameObjectWithTag("airplane"); udpstuff udp = g.GetComponent <udpstuff> (); Quaternion temp = transform.localRotation; temp.x = udp.speed; transform.rotation = temp; }
// Update is called once per frame void Update() { GameObject g = GameObject.FindGameObjectWithTag("airplane"); udpstuff udp = g.GetComponent <udpstuff> (); if (udp.speed > 9f && wait) { InvokeRepeating("ToggleState", startDelay, interval); wait = false; } if (udp.speed > 80f) { CancelInvoke(); rend.enabled = false; } }
// Use this for initialization void Start() { try{ udpServer = new UdpClient(clientPort); } catch (System.Exception e) { print("Couldnt do it foo"); } if (instance != null) { Debug.LogError("There should only be one instance of udp script!"); Destroy(gameObject); } instance = this; }
// Update is called once per frame void FixedUpdate() { //yaw = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick); angleYaw = yaw.x; //OlD GameObject g = GameObject.FindGameObjectWithTag("airplane"); udpstuff udp = g.GetComponent <udpstuff> (); if (udp.heading != 0 && firstTime == 0) { gyroS = udp.heading; // Get initial heading in X-Plane altS = udp.altitude; firstTime++; } velocity = udp.speed; anglePitch = udp.pitch; angleRoll = udp.roll; gyro = udp.heading; altitude = udp.altitude; Vector3 pil = transform.eulerAngles; pil.z = anglePitch; pil.x = angleRoll; pil.y = gyro - gyroS - 90f; transform.rotation = Quaternion.Euler(pil); // GameObject terrain = GameObject.FindGameObjectWithTag ("terrain"); // Vector3 terrainPos = terrain.transform.position; // terrainPos -= 0.4f*(transform.right * Time.deltaTime * velocity); // terrainPos.y = -(0.4f)*(udp.altitude - altS); // terrain.transform.position = terrainPos; GameObject terrain = GameObject.FindGameObjectWithTag("terrain"); Vector3 terrainPos = terrain.transform.position; terrainPos -= 6.67f * (transform.right * Time.deltaTime * velocity); terrainPos.y = -(6.67f) * (udp.altitude - altS); terrain.transform.position = terrainPos; }
// Update is called once per frame void Update() { GameObject g = GameObject.FindGameObjectWithTag("airplane"); udpstuff udp = g.GetComponent <udpstuff> (); yaw = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick); if (udp.speed > 5f && rudder) { direction.text = "Use the left joystick to stay centered"; rudder = false; } if (!rudder && yaw.x > 0.1f && wait) { direction.text = "Wait till the speed hits 80 knots and then pull up"; wait = false; } if (udp.speed > 80f && pullUp) { direction.text = "Pull Up SLOWLY"; pullUp = false; } if (udp.pitch > 20f && tooMuch) { direction.text = "Pulling up too Fast. Push Down to 5 degrees"; tooMuch = false; } if (udp.altitude > 1000f && last) { direction.text = "Fly around. Try and go through the hoops"; last = false; } if (!last && udp.altitude > 1050f) { gameObject.SetActive(false); } }