Unity Community


Page 1 of 5 123 ... LastLast
Results 1 to 20 of 91

  1. Posts
    69

    [sharing] gyroscope-controlled camera on iPhone 4

    Now that Unity 3.4 has support for the iPhone 4 gyroscope it makes a fantastic virtual camera controller.

    Took a bit of work to sort out the various orientation issues, & so I thought I'd save anyone else the trouble.

    Example package attached. Enjoy!

    [updated so that it works even if camera already has a parent ie character controller etc]
    Attached Files
    Last edited by phoberman; 08-08-2011 at 12:03 PM. Reason: update


  2. Location
    Germany
    Posts
    96
    WOHOOO. Great work. Many thanks for sharing your work with us!
    Follow me -> http://lonelyindie.com -> Facebook -> Twitter

    My first released iPhone game: Candy Fever


  3. Posts
    2,247
    Nice work! thanks for sharing!


  4. Posts
    116
    I was wondering if the user acceleration can be used to determine movement of the device itself in 3d space, rather then simply "moving" the camera...


  5. Location
    Ukraine
    Posts
    2
    Great gyro attitude sample! tnx

    userAcceleration works in mistery mode... always Y+ and shaking. and after movement for example forward, returns back..
    i dont understend how it works! ((


  6. Posts
    116
    As far as I could determine so far the userAcceleration is a pure acceleration vector3. For some reason when you "stop" it moves "backwards", the acceleration get's less to a point where it goes to 0.


  7. Posts
    35
    Hi

    Great script!!
    I have a question: is there a way to start the camera facing always compass north?

    Cheers,
    Lucas


  8. Posts
    69
    @JanHelleman: I've played with the accelerometer, and it seems to be useless for translation; I think it's mostly good for getting tilt and shake. Wish it were otherwise.

    @bhaal: When you fire up the gyroscope, it starts out facing whatever direction the phone is facing. You'd need to read the compass to figure out which way is north (I think Prime31 has a plugin) and then you'd need to use a parent transform to compensate for whatever direction the phone is facing on startup.

    Glad it's been useful - I updated the package a little so that it uses only one script (now takes care of creating the necessary parent transform)


  9. Posts
    62
    Hi,
    I have tested your package but it does not work on my iPhone?!!!


  10. Location
    Zürich, Switzerland
    Posts
    26,572
    Quote Originally Posted by Milad View Post
    Hi,
    I have tested your package but it does not work on my iPhone?!!!
    sure its an iphone4?
    other iphones dont have gyros


  11. Posts
    19
    Quote Originally Posted by phoberman View Post
    @JanHelleman: I've played with the accelerometer, and it seems to be useless for translation; I think it's mostly good for getting tilt and shake. Wish it were otherwise.
    Tilt on the X axis or all around? I was looking at some raw #s and it seems decent for the X-axis (i.e. car steering wheel).

  12. kiu kiu is offline

    Location
    Stuttgart, Germany
    Posts
    10
    Thanks a lot. It's so wonderful when you want to do something and it's just been done for you!


  13. Posts
    116
    I was looking for very short distance movement of the device itself. After searching a lot I realized this gyro is A not precise enough for it and B there's to much error in the calculations according to some guy from google... To bad


  14. Location
    Brooklyn, New York
    Posts
    51
    phoberman. This script is the bomb. Thanks for figuring this out man.


  15. Location
    Düsseldorf Germany
    Posts
    672
    phoberman that is a very handy script! I like it .
    This script should be in the official unity wiki scripts section!!!!

    Has anyone tried to use that script with a Caracter Controller?


  16. Location
    Brooklyn, NY
    Posts
    52
    This is a great script, thanks for sharing!

    One thing I've noticed is that when I rotate the phone around the Y axis (i.e. spinning the phone flat on a table), the image does not rotate as fast as the phone. For instance, when I rotate the phone 360 degrees, the image has only rotated about 270 degrees. The other axes seem to work great. Has anyone else noticed this? Any idea what's up?


  17. Location
    Brooklyn, NY
    Posts
    52
    One additional detail that I've determined is that when I rotate the phone 90 in reality, it only registers as 70 degrees.


  18. Location
    Manchester, UK
    Posts
    205
    Thank you for this! Its great!
    iguana_02 - Manchester United Kingdom


  19. Location
    Uberlândia-MG/CampinaGrande-PB/João Pessoa-PB
    Posts
    129
    Thanks for sharing phoberman.
    Your gyroscope is working perfectly.


  20. Location
    Berlin, Germany
    Posts
    13
    Thank you so much for sharing! Great work!!!

Page 1 of 5 123 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •