I wish to rotate my object in the direction it is travelling. How can I calculate the Vector difference from the previous frame and current frame and hence give a direction to aim towards to make it rotate in the direction it is travelling. The following is the code being used to control the object by accelerometer.
Vector3 getAccelerometer(Vector3 accelerator){
Vector3 accel = this.calibrationMatrix.MultiplyVector(accelerator);
return accel;
}
void Start(){
calibrateAccelerometer();
}
void Update(){
Vector3 dir = getAccelerometer(Input.acceleration);
if (dir.sqrMagnitude > 1)
dir.Normalize();
transform.Translate(dir * speed * Time.deltaTime);
}