Question by
riftonne · Jun 08, 2017 at 05:11 PM ·
joystickgyroscope1st person
Switch joystick and gyroscope
I am using Gyro Script to change the view of the player in game and its a mobile based fps game. The problem is if I use gyro to rotate or change camera view the joystick inputs are reversed. How can I fix this and I am using Unity Standard asset and Heyworks gyro script for gyro movement.
this is my Gyroscope script: using System.Collections; using System.Collections.Generic; using UnityEngine;
public class GyroControl : MonoBehaviour {
private bool gyroEnabled;
private Gyroscope gyro;
private GameObject cameraContainer;
private Quaternion rot;
// Use this for initialization
void Start () {
cameraContainer = new GameObject ("Camera Conrainer");
cameraContainer.transform.position = transform.position;
transform.SetParent (cameraContainer.transform);
gyroEnabled = EnableGyro ();
}
private bool EnableGyro (){
if(SystemInfo.supportsGyroscope)
{
gyro = Input.gyro;
gyro.enabled = true;
cameraContainer.transform.rotation = Quaternion.Euler (90f, 90f, 0f);
rot = new Quaternion (0, 0, 1, 0);
return true;
}
return false;
}
// Update is called once per frame
private void Update () {
if(gyroEnabled){
transform.localRotation = gyro.attitude * rot;
}
}
}
When i switch to Joystick that i made for camera i lose controle. The same thing happened when even i switch from joystick to Gyro Can you me please :s
Comment