Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Rotating camera 180 degrees around an object

Discussion in 'General Graphics' started by omatase, May 18, 2016.

  1. omatase

    omatase

    Joined:
    Jul 31, 2014
    Posts:
    159
    I'm using transform.RotateAround to rotate the camera round an object around the Y axis. I want the camera to stop rotating after it has rotated 180 degrees. How do I calculate a point that is rotated around an object 180 degrees given a specific starting point? And how can I test for when my object has reached the target position?

    appreciate any help.
     
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Non-coder solution

    Create a circle spline in 3D app.
    Select 1 of the 4 vertices of the spline and delete it.
    What is left is a semi- circle.
    Create a dummy/null object and path constrain it to the circle.
    Animate the dummy/null along the spline over the number of frames you want the animation to happen in Unity.
    Bake the position/rotation animation into the null and export as fbx.
    In Unity parent the game camera to the animated dummy/null object.
    Use the look at feature in Unity to make the camera look at the object as it moves - while parented to the dummy/null. (this last part [look at] might require code - I've not done it only read about it)
     
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,209
    This is kind of the wrong sub forum for this, the scripting sub forum is probably more appropriate.

    However one way to do this is in the script you're using to call rotate around have a float property that you start at 180 and subtract each update's rotation about from that number and stop when it gets below zero.
     
  4. omatase

    omatase

    Joined:
    Jul 31, 2014
    Posts:
    159
    I did my best to guess which sub forum to post in, is there a way to move my post?
     
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,209
    I don't think there is, a moderator would have to do it.
     
  6. omatase

    omatase

    Joined:
    Jul 31, 2014
    Posts:
    159
    Coo, thanks! I'll C&P.