Created
October 9, 2019 04:27
-
-
Save arkarmintun1/f17327c0e9e4f48a4ca2b51c54ed4fb7 to your computer and use it in GitHub Desktop.
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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Accelerometer: MonoBehaviour | |
{ | |
public bool isFlat = true; | |
private RigidBody rigid; | |
private void Start() | |
{ | |
rigid = GetComponent<RigidBody>(); | |
} | |
private void Update() | |
{ | |
Vector3 tilt = Input.acceleration; | |
if (isFlat) | |
tilt = Quaternion.Euler(90, 0, 0) * tilt; | |
rigid.AddForce(tilt); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment