WHY UNITY WHY? I had just got this script for a gyroscope controlled main camera online, and it was working well. Maybe .1 second lag with the gyroscope, but it was working. I had just made a few edits, otherwise it was the original. When I used the same script in a different, the gyroscope is basically messed up. It flipped the game 90 degrees, and when I tilt it upwards, it moves the camera left. When I tilt it downwards, it goes right. When I move it right, it goes up, and vice versa. Any help would be really really greatly appreciated. I’m stumped, the only change I’ve made is upgraded to unity 4, maybe that could have something to do with it? Thanks,
Here is the script by the way:
// iPhone gyroscope-controlled camera demo v0.3 8/8/11
// Perry Hoberman <hoberman@bway.net>
// Directions: Attach this script to main camera.
// Note: Unity Remote does not currently support gyroscope.
private var gyroBool : boolean;
private var gyro : Gyroscope;
private var rotFix : Quaternion;
function Start() {
var originalParent = transform.parent; // check if this transform has a parent
var camParent = new GameObject ("camParent"); // make a new parent
camParent.transform.position = transform.position; // move the new parent to this transform position
transform.parent = camParent.transform; // make this transform a child of the new parent
camParent.transform.parent = originalParent; // make the new parent a child of the original parent
gyroBool = Input.isGyroAvailable;
if (gyroBool) {
gyro = Input.gyro;
gyro.enabled = true;
if (Screen.orientation == ScreenOrientation.LandscapeLeft) {
camParent.transform.eulerAngles = Vector3(90,90,0);
} else if (Screen.orientation == ScreenOrientation.Portrait) {
camParent.transform.eulerAngles = Vector3(90,180,0);
}
if (Screen.orientation == ScreenOrientation.LandscapeLeft) {
rotFix = Quaternion(0,0,0.7071,0.7071);
} else if (Screen.orientation == ScreenOrientation.Portrait) {
rotFix = Quaternion(0,0,1,0);
}
//Screen.sleepTimeout = 0;
} else {
print("NO GYRO");
}
}
function Update () {
Invoke ("Rotate", 12.8);
}
function Rotate () {
if (gyroBool) {
var camRot : Quaternion = gyro.attitude * rotFix;
transform.localRotation = camRot;
}
}