Search Unity

Auto Mouse Orbit + Mouse Click Orbit

Discussion in 'Scripting' started by slumberus, Dec 12, 2007.

  1. slumberus

    slumberus

    Joined:
    Apr 17, 2007
    Posts:
    39
    Basing on the default Mouse Orbit script, I need to:
    1. Have the camera orbiting an object automatically by itself

    2. Simultaneously allows users to mouse left click on the object and drag so they can rotate the camera themselves

    3. reverts back to auto rotation/orbit when the mouse button is released

    I think I need to place a Mouse click Listening script on the object, which uses getComponent to have the Mouse Orbit script(on the camera) switch to manual rotation and auto rotation. But that's where I got stuck.

    Any pointers? Thanks. :)

    Chris.
     
  2. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    Here is a script that i made and i think it would work (i have not tested it)
    The object would set autorotate to true when the mouse is over it and it presses Input.GetAxis ("MouseLeft") (you have to set MouseLeft in input settings).

    GoodLuck

    Notify me if you get the script to work.
     

    Attached Files:

    UnityLighting likes this.
  3. slumberus

    slumberus

    Joined:
    Apr 17, 2007
    Posts:
    39
    Thanks sture!

    I just got the code, was fixing some minor syntax errors, and adding the mouseleft portion now.

    Will let u know the results! :D