// Update is called once per frame void Update() { if (apidou.getState() == APIdou.State.Receiving) { txt.text = "Name: " + apidou.getName() + "\nTotal acceleration: " + apidou.getTotalAcceleration() + "g"; if (apidou.isTouched(APIdou.BELLY)) { txt.text += "\nBelly is touched !"; } txt.text += "\n" + apidou.getPosition(); if (apidou.getPosition() == APIdou.Positions.Standing) { txt.text += "\nAPIdou is standing"; } bool isMoving = Mathf.Abs(apidou.getTotalAcceleration() - 1.0f) > 0.2f; txt.text += "\n\n"; txt.text += isMoving ? "IS MOVING" : "not moving"; } else { loader(); } }
// Update is called once per frame void Update() { float rotation_z = (APIdou.accel [0] / 16384.0f) * 90.0f; float rotation_x = (APIdou.accel [2] / 16384.0f) * 90.0f; transform.rotation = Quaternion.Euler(new Vector3(rotation_x, 0, -rotation_z)); if (APIdou.isTouched(APIdou.ANTENNA)) { Debug.Log("Antenna Touched"); } }