Mapping accelerometer to camera

Has anyone tackled (and solved) mapping the iPhoneInput accelerometer’s (Vector3) to a camera’s rotation (Vector3)? Not just for rotating from portrait to landscape view (on only one axis) but, in all three axis.

So that when the iphone is laying flat the camera is looking straight down, when the iphone is tilted the camera rotates in the same direction. This would be like a first-person point of view… like you are looking through the iphone into a virtual world. Do you think is this even possible?

It’s possible. I played some egg catching game that did this. It was novel, and would be pretty cool with a game that was good, I would think. :wink:

While continuing to research how to do this and I found an article and plugin on the Unity Wiki that lets you use a Wii Remote, and noticed that the plugin has functions to return Roll, Pitch and Yaw. I’m pretty sure that is what I need to calculate from the iPhone’s accaccelerometer’s Vector3 data in order to make this possible.

Does anyone have ideas on how to calculate Pitch-Yaw-Roll from the iPhoneInput Vector3 data? This would be a great function to give to the Unity community. Anyone want to help?

After more research, I’m beginning to doubt if the iPhone’s accelerometer supplies enough information to do what I want. The reason is because the accelerometer only determines the direction gravity is pulling, it doesn’t contain directional (compass) information. For this reason Yaw cannot be determined. bummer.

http://www.invensense.com/support/library.html

You can get the effect you want, but you have to get input from the user as to how they are tilting the thing, and the game has to trust them. 8)

…until there’s a gyroscope inside.

I had been thinking about this, and what I’d be doing is just use two directions (“tilt” and “up/down”), most important being “up/down”. That won’t give the complete experience - but I’m hoping it will be enough fun :wink: … for turns around y (that would be “rotate”), I’ll probably add touch control plus do some “auto-rotate” depending on the game. I’d also use touch control for getting the camera closer or more distant.

One issue, however, is that I won’t rotate the camera itself but instead rotate the camera around the object, and the camera usually will be “pretty distant” from the actual object. So that might break immersion harshly … I’ll report on my experiences :wink: