Can someone please help me. I have a tilt function that takes the accelerometer input from a mobile device to rotate my player which works but the rotation is really shakey. I have been doing research and everyone is pretty much saying to use Lerp instead of Euler but every time I have tried I have been unsuccessful in converting the script. Can someone please help me with converting from Euler to Lerp or give me suggestions on a better way of achieving my desired outcome.
public float speed = 1f;
private Vector3 myRotation;
public Transform particle;
void Start() {
myRotation = gameObject.transform.rotation.eulerAngles;
}
void Update() {
//float GetComponent<ParticleSystem>().GetComponent<Rigidbody2D>().transform.position.x
if (Input.acceleration.normalized.x > 0) {
myRotation.z = Mathf.Clamp (myRotation.z - 1f, -60f, 45f);
transform.rotation = Quaternion.Euler (myRotation);
}
if (Input.acceleration.normalized.x < 0) {
myRotation.z = Mathf.Clamp (myRotation.z + 1, -60f, 45f);
transform.rotation = Quaternion.Euler (myRotation);
}
}
here is an a quick image I made up in paint to show what I want to happen.
