Skip to content

Instantly share code, notes, and snippets.

@poemdexter
Last active August 29, 2015 14:00
Show Gist options
  • Save poemdexter/11022613 to your computer and use it in GitHub Desktop.
Save poemdexter/11022613 to your computer and use it in GitHub Desktop.
phone tilt left/right to move thing left/right
using UnityEngine;
using System.Collections;
public class TiltController : MonoBehaviour
{
public float speed;
void Update()
{
Vector3 dir = Vector3.right * Input.acceleration.x;
if (dir.sqrMagnitude > 1)
dir.Normalize();
transform.Translate(dir * Time.deltaTime * speed);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment