Hi friends, I'm trying to create an script for parallaxing effect on main camera for my menu using accelerometer from mobiles...I done this so far :
using UnityEngine;
using System.Collections;
public class CameraMP : MonoBehaviour {
public float horizontal = 0.0f;
public float vertical = 0.0f;
public float cameraSpeed = 0.5f;
void Update() {
horizontal += Input.acceleration.x * cameraSpeed;
vertical -= Input.acceleration.y * cameraSpeed;
transform.rotation = Quaternion.Euler(vertical , 0.0f, 0.0f);
if (vertical >= 3f) {
transform.rotation = Quaternion.Euler(-vertical , 0.0f, 0.0f);
}
/*if(vertical >= -3f) {
transform.rotation = Quaternion.Euler(vertical , 0.0f, 0.0f);
}*/
}
}
*But how to add limits for camera rotation not performing full rotation ...or how to make it work another way...some suggestions will be much appreciated, thanks !
Example: http://matthew.wagerfield.com/parallax/
↧