Created
February 18, 2016 01:04
-
-
Save mattshapiro/5e812ad45ca561253996 to your computer and use it in GitHub Desktop.
Unity 5 Accelerometer-based game object rotation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float x = -Input.acceleration.x * 180; | |
float y = Input.acceleration.y * 180; | |
x = limit (x, MAX_ANGLE); | |
y = limit (y, MAX_ANGLE); | |
Quaternion quato = Quaternion.Euler(y, 0, x); | |
rb.transform.rotation = Quaternion.Lerp(rb.transform.rotation, quato, Time.deltaTime * 5.0f); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment