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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Hints on second camera view?

Discussion in 'Scripting' started by mirzahat, Aug 19, 2015.

  1. mirzahat

    mirzahat

    Joined:
    Dec 21, 2014
    Posts:
    53
    Hello,

    I want to implement a secondr camera view in the corner of the screen to display some closeups etc.

    What tutorials should I use?

    Is it even possible?

    I heard that Unity Pro is required, however I use the personal editin so far.

    Mirza
     
  2. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    Not required at all.
    1. Make a second camera in the scene and make sure the tag for this camera is NOT set to "Main Camera".
    2. Give it a depth value that's higher than your main camera's depth (so it renders later than the main camera, ie: after, and thus "on top of"). If you main camera's depth is -1 (normal), then make this one 0 or higher.
    3. Lastly, just give it viewport rect settings that match the area of the screen where you want it to be shown.
    For the rect, it's "0 to 1" as a percentage of the screen width/height. For setting the camera to the lower-right corner, you could for instance set it to like...
    • X: .55
    • Y: .05
    • Width: .4
    • Height: .4
    Which translates to "X starts at 55% of screen width (from the left), Y starts at 5% of screen height (from the bottom), Width is 40% of the screen width, Height is 40% of the screen height". Get it? ^_^
     
    Last edited: Aug 19, 2015
  3. mirzahat

    mirzahat

    Joined:
    Dec 21, 2014
    Posts:
    53
  4. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    The second camera shows whatever the second camera is looking at- if you want to zoom it, then you need to move the camera closer. You're probably going to have to make a script that tracks whatever it is in the scene you want it to look at, at which angle and what distance, etc...
     
  5. mirzahat

    mirzahat

    Joined:
    Dec 21, 2014
    Posts:
    53
  6. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    Z parameter works almost identically, provided that you have it set to perspective and not orthographic. The field of view will actually give you a pretty ugly distortion effect if you mess with it too much, whereas the Z parameter is always clear- just be careful not to set the near clipping plane too far away.

    Have fun!
     
  7. mirzahat

    mirzahat

    Joined:
    Dec 21, 2014
    Posts:
    53
    Thanks, that helped a lot.

    Anyway, quick question since you seem to have more experience with Unity:

    I have a problem setting a rigidbody to halt programmatically.

    The game balls move sometimes very slowly and simply dont stop!

    I tried:

    rigidbody.velocity = Vector3.zero;
    rigidbody.angularvelocity = Vector3.zero;


    I even set an Invoke function to try to stop the balls after a few secs.

    Any ideas?

    Mirza
     
  8. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    Try setting a higher angularDrag. From the description, I'm guessing it's pretty close to zero.
     
  9. mirzahat

    mirzahat

    Joined:
    Dec 21, 2014
    Posts:
    53
    What is higher?

    I mean, if it was 0, could it be 0.5 , or more?
     
  10. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    Trial and error, but yes it shouldn't take a very high number at all to see an effect. Try normal drag too, if that doesn't quite work for you.
     
  11. mirzahat

    mirzahat

    Joined:
    Dec 21, 2014
    Posts:
    53
    thanks so much!