Skip to content

Instantly share code, notes, and snippets.

@arkarmintun1
Created October 9, 2019 04:27
Show Gist options
  • Save arkarmintun1/f17327c0e9e4f48a4ca2b51c54ed4fb7 to your computer and use it in GitHub Desktop.
Save arkarmintun1/f17327c0e9e4f48a4ca2b51c54ed4fb7 to your computer and use it in GitHub Desktop.
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