Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Going mental trying to do a simple camera rotation ... ugh!

Discussion in 'Scripting' started by DaveyJJ, Aug 19, 2005.

  1. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    I'm simply trying to move a camera from it's starting position and rotation, to another position and rotation. I cam move it, but can't figure out the stupid simple code required to rotate it too. Argh, can someone please whack me upside the head and put me out of this misery??? :!:

    Code (csharp):
    1.  
    2. var gameCamera : Transform;
    3.  
    4. function OnMouseDown ()
    5. {
    6.    /* move camera to it's game position */
    7.     gameCamera.position = Vector3 (0.3233052,8.744491,7.637483);
    8.     CAMERA ROTATION GOES HERE!
    9.  
    10.     /* cameras previous position is ...
    11.     -0.7878647,18.43345,-25.51621 and rotation is
    12.     44.70861,-0,-0  for later reference */
    13.      
    14. }
    15.  
    I know it has something to do with Quaternion stuff but I'm pulling what little hair I have left out. Grrr....
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Do you mean you want to slowly interpolate towards another rotation?
    Or do you want to do a sudden change of the rotation?
     
  3. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    One way one second, then zap to the other rotation. Thanks for taking a few minutes of precious coding time to answer such a simple thing, Joe.
     
  4. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    // Those are the rotation values you see in the inspector
    transform.eulerAngles = Vector3 (0, 5, 10);
     
  5. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    Euler, of course! <kicks self>