Skip to content

Instantly share code, notes, and snippets.

@gkagm2
Created April 20, 2019 00:11
Show Gist options
  • Save gkagm2/d6a70fae89b9611a2cafdd4e1962e7dc to your computer and use it in GitHub Desktop.
Save gkagm2/d6a70fae89b9611a2cafdd4e1962e7dc to your computer and use it in GitHub Desktop.
KeyMovePhone
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class csKeyMovePhone : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Vector3 dir = Vector3.zero;
dir.x = -Input.acceleration.y;
dir.z = Input.acceleration.x;
if (dir.sqrMagnitude > 1)
dir.Normalize();
dir *= Time.deltaTime;
transform.Rotate(dir * 10.0f);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment