Gyro camera control with forward and backward movement
hi , i am creating setup(a room) in which i want to move and rotate the camera with gyro , rotation is working fine,but i also want to have forward and backward movement if user clicks a button (like an fps controller). I am able to move camera too in forward and backward position,but the problem is the camera is moving forward in the direction camera is facing.like if i am pointing on the floor then its moving in the floor ,what i want is movement like an fps controller. i have tried using fps controller and adding gyro in it ,but its not working
heres my gyro script with a camera
public class gyrooo : MonoBehaviour {
 Quaternion origin=Quaternion.identity;
 Quaternion rotFix;
 Vector2 move;
 public Text gyroAngle;
     GameObject camParent;
 void Start() {
 Input.gyro.enabled=true;
     camParent = new GameObject ("CamParent");
     camParent.transform.position = transform.position;
     transform.parent = camParent.transform;
     camParent.transform.Rotate (Vector3.right, 90);
 }
   public void gyroo(){
     rotFix = new Quaternion (Input.gyro.attitude.x, Input.gyro.attitude.y, -Input.gyro.attitude.z, -                          Input.gyro.attitude.w);
     transform.localRotation = rotFix;
 }
 
 public void FixedUpdate(){
     getInput ();
     gyroo();
 }
 public void getInput(){
 
     float vertical = 0f;
             if (Input.touchCount > 0)
             {
                 var touch = Input.GetTouch(0);
                 if (touch.position.x < Screen.width/2)
                 {
                     transform.Translate (Vector3.back*Time.deltaTime);
            (transform.localPosition.x,0,transform.localPosition.z);
                 }
                 else if (touch.position.x > Screen.width/2)
                 {
                      transform.Translate (Vector3.forward*Time.deltaTime);
            (transform.localPosition.x,0,transform.localPosition.z);
                 }
                 else{
                 //    vertical = 0;
                 }
             }
             else {
             //    vertical = 0;
             }
         
 }
also the rotation from gyro is very sensitive..is there a way to decrease its sensitivity..i have tried many ways for gyro movement suggested on this forum and this is the best one i found..the only problem is its a little sensitive.
can anyone please help me in this problem......its been 10 days .
Answer by Th4nkfull · Mar 12, 2018 at 02:43 PM
transform.localPosition TO transform.globalPosition,use globalPosition instead of localPosition
i know this is from 2k16
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                