- Home /
Question by
RoyalCoder · Oct 04, 2014 at 04:56 AM ·
androidiosmobileparallax
Parallax mobile menu
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/
Comment
Your answer
Follow this Question
Related Questions
Is it possible to send SMS from an action in Unity? (Mobile iOS or Android) 1 Answer
Native list views on Mobile? 0 Answers
Unity 5 mobile single stick control 6 Answers
Different animations on mobile 0 Answers
Mecanim for Mobile Devices 2 Answers