Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- [AddComponentMenu("Camera/Camera Rotate")]
- [RequireComponent (typeof (AccelerometerInputBehaviour))]
- public class CameraRotate : MonoBehaviour {
- public JoystickBehaviour joystick;
- public float rotateSpeed = 80.0f;
- private AccelerometerInputBehaviour accel;
- private Quaternion startRotation;
- private Quaternion startRotationInvert;
- void Start () {
- startRotation = transform.localRotation;
- startRotationInvert = transform.localRotation;
- startRotationInvert.y += 180;
- accel = GetComponent <AccelerometerInputBehaviour> ();
- }
- void Update () {
- if (joystick.output.y > 0 || Input.GetAxis ("Vertical") > 0)
- transform.localRotation = startRotation;
- else if (joystick.output.y < 0 || Input.GetAxis ("Vertical") < 0)
- transform.localRotation = startRotationInvert;
- else
- transform.Rotate (Vector3.up, rotateSpeed * accel.output * Time.deltaTime);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement