- Home /
iPhone acceleration events problem
I'm having a problem getting Unity to display a change in acceleration events using the Unity Remote app. Is this correct or is it possible that the resulting numbers are so small they're not registering? Here's the code... quoted from the Unity Script Reference:
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void Update() {
Vector3 acceleration = Vector3.zero;
foreach (AccelerationEvent accEvent in Input.accelerationEvents) {
acceleration += accEvent.acceleration * accEvent.deltaTime;
}
print(acceleration);
}
}
Answer by gribbly · Oct 05, 2011 at 12:24 AM
Why don't you just do:
void Update() {
Vector3 acceleration = Vector3.zero;
acceleration = Input.acceleration;
print(acceleration);
}
...?
Because that Input.acceleration only gives the last value from the sensor. Using Input.accelerationEvents you can get every value gotten from the sensor during the last frame, resulting in a much more precise information.
Your answer
![](https://koobas.hobune.stream/wayback/20220612095649im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
iPhone tilt Control 0 Answers
Zero-ing the Input.acceleration.z 0 Answers
Does the iPhone use it's GPU when using the Unity remote? 1 Answer
How to offset Input.Acceleration by 90 degrees 1 Answer
iPhone Gyroscope problem 0 Answers