Created
April 20, 2019 00:11
-
-
Save gkagm2/d6a70fae89b9611a2cafdd4e1962e7dc to your computer and use it in GitHub Desktop.
KeyMovePhone
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 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