public void steerBall(AccelerometerControllerType accelerometer) { //data accel.x = accelerometer.ACCELERATION_X; accel.y = accelerometer.ACCELERATION_Y; accel.z = accelerometer.ACCELERATION_Z; //accelerometers due to gravity can really only sense 2 axis (can't filter out gravity) //here we convert those 2 axis into horizontal and vertical and normalize horizontal = EasyWiFiUtilities.relativeAngleInAxis(Vector3.up, -accel, Vector3.forward) / normalizeDegrees; vertical = EasyWiFiUtilities.relativeAngleInAxis(Vector3.up, -accel, Vector3.right) / normalizeDegrees; horizontal *= -sensitivity; vertical *= -sensitivity; actionVectorPosition.x = horizontal; actionVectorPosition.y = 0f; actionVectorPosition.z = vertical; myRigidbody.AddForce(actionVectorPosition); }
// Use this for initialization void Awake() { accelerometerKey = EasyWiFiController.registerControl(EasyWiFiConstants.CONTROLLERTYPE_ACCELEROMETER, controlName); accelerometer = (AccelerometerControllerType)EasyWiFiController.controllerDataDictionary[accelerometerKey]; }