Search Unity

How to make a scope which only zooms in the scope not the background

Discussion in 'Scripting' started by Nikdy98, Jul 27, 2011.

  1. Nikdy98

    Nikdy98

    Joined:
    Jul 6, 2011
    Posts:
    192
    Like Red Orchestra: 2

    Also im sure this will require scripts thats why i post in scripting :)
     
  2. Nikdy98

    Nikdy98

    Joined:
    Jul 6, 2011
    Posts:
    192
    like this

     
  3. Nikdy98

    Nikdy98

    Joined:
    Jul 6, 2011
    Posts:
    192
    plz i really need this
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Unless you have unity pro, it is not possible since it is using render to texture. If you want to be really stupid you can try rendering a second (square) camera over the scope, then another camera on top of that to hide the corners of the square. It will be ugly. You need unity pro to do this kind of thing.

    Alternatively you could grab a depth cut-out shader from the unity wiki, and render it on the scope, then another camera which renders behind everything else for the zoomed in bit. But these are all really bad ideas, and render to texture is the only real proper solution.
     
  5. Nikdy98

    Nikdy98

    Joined:
    Jul 6, 2011
    Posts:
    192
    Yes i do have unity pro
     
  6. Nikdy98

    Nikdy98

    Joined:
    Jul 6, 2011
    Posts:
    192
    So how do i render to texture?
     
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Read the docs.
     
  8. Nikdy98

    Nikdy98

    Joined:
    Jul 6, 2011
    Posts:
    192
    Not the docs, i hate those..
     
  9. Nikdy98

    Nikdy98

    Joined:
    Jul 6, 2011
    Posts:
    192
    Alright i made a new render texture now what do i do? I made the target texture the render texture and idk then :(
     
  10. Nikdy98

    Nikdy98

    Joined:
    Jul 6, 2011
    Posts:
    192
    alright how can i find a transparent material?
     
  11. Nikdy98

    Nikdy98

    Joined:
    Jul 6, 2011
    Posts:
    192
    Alright this isn't working. Am i supposed to put the render texture onto a plane and then put the plane in the scope?
     
  12. SomeGuy22

    SomeGuy22

    Joined:
    Jun 3, 2011
    Posts:
    722
    Looking really nooby with the quadruple post...

    Yes the method you're looking for involves making a circle (or an object already with the same dimensions as the scope) and putting a texture that is the view of another camera on it. Just enable/disable the renderer when needed and move the camera in and out or change the perspective. (too lazy to look up the technical term)
     
  13. Nikdy98

    Nikdy98

    Joined:
    Jul 6, 2011
    Posts:
    192
    Sorry for quad post i am noobz.

    But do i put the camera as child to the cam that zooms in?
     
  14. HolBol

    HolBol

    Joined:
    Feb 9, 2010
    Posts:
    2,887
    How can you be a noob, but have the money to shell out $1.5k for a piece of software? this, my friend, does not add up.
     
  15. Nikdy98

    Nikdy98

    Joined:
    Jul 6, 2011
    Posts:
    192
    I am learning maybe?
     
  16. Nikdy98

    Nikdy98

    Joined:
    Jul 6, 2011
    Posts:
    192
    I just want to have a realistic scope :(
     
  17. Connor

    Connor

    Joined:
    Jul 11, 2011
    Posts:
    21
    First: create a new rendertexture and camera
    Second: make the target render thing of the camera be the new rendertexture
    Third: place the camera in front of the scope model make the Fov about 2-5
    Fourth: apply the rendertexture to the lens (glass) of the scope
    If the scope looks weird then it is probably the lens piece if so then use a modeling program such as Blender, Cinema 4d, or 3ds max to make a square then cut the edges into a circle
    You might want an aiming script to make the model move to where you want it I recommend
    http://www.unifycommunity.com/wiki/index.php?title=AimDownSights
    But you will need to change so of the numbers in the script to fit with your model
    Hope this helps
     
  18. Nikdy98

    Nikdy98

    Joined:
    Jul 6, 2011
    Posts:
    192
    Wish you would've come along earlier o_O I actually figured it out last night :)
     
  19. CheyTac

    CheyTac

    Joined:
    Feb 17, 2011
    Posts:
    71
    I just did that yesterday.

    Create a Camera in the scope, create a new render texture, in the camera that you created set that new render texture to the target texture, now in your scope create a flat cilynder and put it in your scope, now create a material with the Render Texture oh and low down you camera FOV.

    :D

    ______________________
    oh srry i didn't see that you've figured it out. Anyway...
     
    Last edited: Jul 28, 2011
  20. RealSoftGames

    RealSoftGames

    Joined:
    Jun 8, 2014
    Posts:
    220
    this is all good and true, but what about the scopes that are not aligning to the centre of the screen, this is causing a really big issue when they 2 cameras are aligned in the view but they are not in the game when zoomed it is off center, and every time i correct this it does it again. any idea what it is caused by?
     
  21. HolBol

    HolBol

    Joined:
    Feb 9, 2010
    Posts:
    2,887
    I would recommend you check the date of the last post in this topic before becoming Dr Frankenstein.