Hi all,
I have a minor coding issue. This code, err, “shakes the monkey” correctly but regardless of the orientation/rotation of the scene objects, it immediately wobbles the monkey forward when you hold the screen at a normal viewing angle (approx 15 degrees tipped back from vertical, upright).
What do I add to tell it that laid flat down is actually 70 degree backwards and that a normal upright held position is where to assume the y orientation is 0 and then to tip forward only when the device gets tipped so that the top of the device is now straight up?
function FixedUpdate () {
var accelerator : Vector3 = iPhoneInput.acceleration;
x = accelerator.x * 15;
y = accelerator.y * 15;
cameraRelativeX = Camera.mainCamera.transform.TransformDirection (Vector3.right);
cameraRelativeY = Camera.mainCamera.transform.TransformDirection (Vector3.forward);
shake = cameraRelativeX * x + cameraRelativeY * y;
bodies = FindSceneObjectsOfType (Rigidbody);
for (var body : Rigidbody in bodies)
{
body.AddForce (shake);
}
}
This is sort of what I’m attempting …
function FixedUpdate () {
var accelerator : Vector3 = iPhoneInput.acceleration;
x = accelerator.x * 15;
y = accelerator.y * 15;
cameraRelativeX = Camera.mainCamera.transform.TransformDirection (Vector3.right);
cameraRelativeY = Camera.mainCamera.transform.TransformDirection (Vector3.forward);
shake = cameraRelativeX * x + cameraRelativeY * y (-70degrees);
bodies = FindSceneObjectsOfType (Rigidbody);
for (var body : Rigidbody in bodies)
{
body.AddForce (shake);
}
}
Does it somehow involve iPhoneOrientation.FaceUp?
Thanks!