Search Unity

Over shoulder zoom and iron sight zoom for TPS game

Discussion in 'Cinemachine' started by a-t-hellboy, Jan 29, 2019.

  1. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    180
    Hey guys,

    Currently, the TPS camera is set up. Now I want to add 2 types of zooming like PUBG, over shoulder zoom and iron sight zoom. What is the best way to achieve this ? (I know some ways but I'm not sure which one is the best)

    Capture.PNG
     
    sd1515 likes this.
  2. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    180
  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
  4. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    180
    @Gregoryl Hey there,

    These are my settings for Normal TP camera:
    TPCamera1.PNG TPCamera2.PNG

    And these are for my over shoulder zoom camera:
    OverShoulderCamera.PNG OverShoulderCamera2.PNG

    The only difference is field of view. Also I checked that Inherit position check box.

    https://gyazo.com/c593feafd2ebed2fd1cf8a0f5cfa8cee
    As you see the problem is when I zoom in the camera doesn't look to the specific point and it is different between TP and over shoulder camera.
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    How interesting. Looks ok on the surface, it should be working. Can you package and post a lightweight project that exhibits this? It's much easier for me to just look at it directly instead of a whole lot of back-and-forth.
     
  6. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    180
    Can you give me an email address ?
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Hey a-t,
    You can just PM it directly to me here. It's best if you can make it a really small project, with just the camera in it. Strip out all the heavy art.
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Thanks for posting your project. The problem is that the Screen Y of all Aim components of all FreeLook rigs needs to be set at 0.5, otherwise you will not have pure movement on the camera Z axis when you switch cameras. Set them all 0.5 and it works like a charm.

    upload_2019-2-11_8-57-3.png
     
    a-t-hellboy likes this.
  9. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    180
    @Gregoryl Thanks you very much. As you said it works like a charm but I have another problem. I'm showing it in the gif.

    https://gyazo.com/59cb8167a0efbfbb24e5eb7a0753496e

    I move my mouse very quickly then I aim quickly by the weapon. As you see there is some movement after aiming. How should I fix it ?

    Also do you have any idea how can setup camera for aiming with ironsight ? Something like PUBG when it is in TPS mode.
     
    Last edited: Feb 12, 2019
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    It's because you have your axis accel/decel values set too high. It makes the movement very soft and bad for precision. Change all accel/decel to 0.01 and it works much better.

    Also: I highly recommend that you upgrade CM to the latest 2.2.8.
     
    a-t-hellboy likes this.
  11. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    180
    @Gregoryl Thank you very much. It works like a charm now :D (Also I just upgraded)

    What about the ironsight camera like PUBG in TPS mode ?

    Ref :
    (A few seconds after this time)


    Do you think it is just switching from TPS to FPS ?
    BTW how set this kind of camera ? (Regular aiming in FPS games)
     
    Last edited: Feb 13, 2019
  12. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    The camera is changing position, and moving off the Z axis, while keeping the object under the reticle fixed. I think the only way you'll be able to do that is to do a raycast to find the object under the reticle (you have its axis, but you need its depth from the camera). Once you have its world position, you can aim the camera at it properly, from wherever it's positioned. The only way to keep the reticle fixed otherwise is to move the camera only along its z axis.
     
    a-t-hellboy likes this.