Search Unity

How To Make a Aim camera with Cinemachine

Discussion in 'Cinemachine' started by Ozker, Jul 14, 2019.

  1. Ozker

    Ozker

    Joined:
    Jul 3, 2019
    Posts:
    10
    Hello There,

    I'm making a 3rd Person Shooter and for the moment the things are going well, now I'm doing the aim and this is where the things get complicated.

    While the character is walking the camera is like the one in The Last of Us, God of War etc (the one that where you are facing is the forward direction) and now I want to make the aim mecanic. I'm thinking about put the camera over the soulder with a little bit of zoom, the problem is I also want that where is facing is the forward direction and I dont know if cinemachine can help in some way or is more coding.

    I used a freelook camera for walking and I make the forward direction by code.

    Thanks so much for reading my post.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Try this scene. Is it close to what you want?
     

    Attached Files:

    Ozker likes this.
  3. Ozker

    Ozker

    Joined:
    Jul 3, 2019
    Posts:
    10
    Thank you Gregoryl for your help but the sceene have some errors becouse there isn't any virtual cameras, how I set the sceen to be able to play and know if this is what I want?


    Captura.PNG
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    You need to import Cinemachine from the package manager.
     
  5. Ozker

    Ozker

    Joined:
    Jul 3, 2019
    Posts:
    10
    Yes! is exactly what I wanted to do thank you Gregoryl!

    Now the question is how to translate it to my project...
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    The scene is very simple. There is a main vcam, which is targeting the player, and a secondary "Aim" vcam which gets activated when an event happens. Make similar vcams, and use your character as the target.
     
  7. Ozker

    Ozker

    Joined:
    Jul 3, 2019
    Posts:
    10
    how do you "teleport" the aim camera to the other camera when you aim?
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Check the "Inherit Position" checkbox in the vcams
     
  9. Ozker

    Ozker

    Joined:
    Jul 3, 2019
    Posts:
    10
    I'm doing my best for copy it to my proyect but i really can't. The inherit positions does it in the inverted direction and then the aim cam doesn't follow the character.

    Any advise or something I can try?
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Perhaps you could show an image of your vcam inspector? Also of your project hierarchy, showing the player, the main camera, and the vcam.
     
  11. Ozker

    Ozker

    Joined:
    Jul 3, 2019
    Posts:
    10
  12. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Your main camera must not be a child of the player. Make it a separate game object, with no parent.
    Also, if you're trying to reproduce what I sent you, set the vcam Body to Framing Transposer, not Transposer.
     
  13. Ozker

    Ozker

    Joined:
    Jul 3, 2019
    Posts:
    10
    Okay, sorry for not replying but I was on hollydays, now what should be the next step?
    Is there any problem if the main camera is a free look camera instet of a virtual camera?
     
  14. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    What I sent you is an alternative to FreeLook. It gives similar results, but uses a vcam. If you want to use a FreeLook instead, then you will need a different solution.
     
  15. Ozker

    Ozker

    Joined:
    Jul 3, 2019
    Posts:
    10
    In the example scene ther is only one script that activate or desactivaet the camara so how do you do to tranform a virtual camera to a really cool third person camera?
     
  16. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    I'm not sure I understand the question. The scene had two 3rd-person cameras: one for "normal" and one for Aim. The script activated the Aim one on demand.
     
  17. Ozker

    Ozker

    Joined:
    Jul 3, 2019
    Posts:
    10
    The question is how you set the virtual camara like in the proyect, and if also you know how it would work with a virtual camera
     
  18. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Make a virtual camera.
    Assign its targets to your player character.
    Look at the virtual camera inspector in the sample project, and set the exact same settings in yours.
     
  19. josephjohn385

    josephjohn385

    Joined:
    Nov 22, 2019
    Posts:
    1
    Hi ,
    I am new unity use , sometimes my gameobject glued over CM Vcam , even I move the game object on x ,y,z axis but camera also moves with simultaneously even though there is nothing in the game window Screenshot_20191219-162727.png
     
  20. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Looks like you have more than one camera in your scene. Can you open up the hierarchy and show a clear picture of it? I need to see what is parented to what.
     
  21. HarrisonJunior

    HarrisonJunior

    Joined:
    Nov 24, 2019
    Posts:
    1
    Hi!O centro da câmera muda quando eu alterno entre eles. Existe alguma maneira de corrigir isso?
     
  22. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Google Translate tells me you're saying this:
    Hi! The center of the camera changes when I switch between them. Is there any way to fix this?

    It's not too clear what you mean by "center of the camera". Can you post images of the problem, and images of the inspectors for the virtual cameras?
     
  23. DavieCud

    DavieCud

    Joined:
    Sep 26, 2020
    Posts:
    2
    Hi Gregoryl

    I know this is an old post, but I would like to thank you for sharing your ideas and Aim Scene. I have been trying many other ways to get my 3rd person shooter aim zoom working, including blending animator layers to get the effect correct but after having used some ideas from here regarding the 3rdPersonAimCamera I have now achieved what I had been hoped to achieve.

    I hope the OP got a solution for his project.

    Thanks again for sharing.

    Regards,
    DavieCud
     
    odaimoko and Gregoryl like this.
  24. teel1ng

    teel1ng

    Joined:
    Jan 14, 2016
    Posts:
    7
    Hi Gregoryl,

    Apologies for necro-posting (same as person before me), but I'd like to thank you for sharing your example. It is straightforward to use and I was able to utilize it (with some adjustments in my game). Now I have (imperfect) aim camera that can be invoked on key press, which I aim (no pun intended) to utilize for spell casting.

    Thanks again for your help!
     
    harlandpj and Gregoryl like this.