Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Third Person Brawler Camera

Discussion in 'Cinemachine' started by pherrera25, Dec 21, 2020.

  1. pherrera25

    pherrera25

    Joined:
    Mar 5, 2018
    Posts:
    11
    Hello!

    I am trying to get started on a third person brawler camera that keeps the main character mostly on the same position and tries to focus on the opponent. (Flipping sometimes when necessary)

    An example for this is Honkai Impact 3rd
    on timestamp 9:40.

    I think I could use a free look camera that looks at my character and the target for this, but if I want to keep my character mostly at the same location on the screen (like pubg third person) but the camera to automatically rotate to face the opponent (no manual camera controls) ... would that be a setting on the free look too?

    Thank you!
     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Hi,

    A possible solution would be to follow the player, and look at the player and the opponent using TargetGroup. In Honkai Impact 3, it looks like there is a targetting system that selects which opponent is in focus. You would do this by writing a script that dynamically adds opponents to the TargetGroup or removes them from the TargetGroup.

    The behaviour of the camera (freelook, framing transposer + pov, etc) is up to you depending on what you'd like to have.
     
  3. pherrera25

    pherrera25

    Joined:
    Mar 5, 2018
    Posts:
    11
    Sounds good, but if I want to take the target group, while making sure the my character is roughly at the same position on the screen (almost over the shoulder) ... would that the same setup?

    I want the camera to just rotate around my character to better frame the target
     
  4. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Is this the behaviour you are looking for?
     

    Attached Files:

  5. pherrera25

    pherrera25

    Joined:
    Mar 5, 2018
    Posts:
    11
    Yes correct! But the player character would be a bit offset from the center, to the left.

    Thank you!
     
  6. pherrera25

    pherrera25

    Joined:
    Mar 5, 2018
    Posts:
    11


    This video shows the behavior perfectly at around 7:40, which the camera automatically rotates to keep the target on the screen and the player at overall the same scree location.
     
  7. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    You can use 3rd Person Follow (body) and Do nothing (aim) on your vcam to achieve that, because the player (Kratos) is always looking at the enemy, when Kratos is targeting an enemy. The Follow target is the player and Look At target is empty. 3rd Person Follow uses the player's forward to orient the camera.

    Turn off damping on 3rd Person Follow.

    Now you'll have a simple vcam something like on the attached image.

    To add more fun to the camera motion, I would add noise.
    I'd add a general slight hand held noise using the Noise part on your vcam to give a more natural feel to the camera. Then, I would add impulses (using Cinemachine Impulse Noise) to certain events that would add extra shake to the camera. For example, when you get hit you add a little shake. If your block is broken (like at 7:44-7:48), then you can add a bigger shake. Or when you crush your enemies with a devastating combo attack (like that shield bash at 7:51-7:53), then you can add a little explosion originating from the enemy's body at the killing blow to shake the camera a bit.

    Speaking of combo attacks, once a combo is activated you know what the player animation is going to do. You can add special vcams that are specifically for showing a combo attack (like at 7:55-7:57). When a combo is triggered, just simply switch to this special vcam. When the combo ends, you switch back to your base vcam. If you are using States for animations, then you can hook up those animation states with StateDrivenCamera to get a simpler workflow.
     

    Attached Files:

  8. pherrera25

    pherrera25

    Joined:
    Mar 5, 2018
    Posts:
    11
    Thank you so much! It's getting pretty close. I am playing around with noise too for feel and it's great.

    One thing I noticed is that I would not want the camera to not be completely locked to facing. The below video as an example on 6:21, where Kratos attacks an enemy on the left, and the camera doesn't snap to that facing position because that would be unnecessary.



    Sometimes if the rotation aim difference is quite small, I'd want a more smooth transition as well instead of a snap on the camera. Would the solution be to use Composer as Aim and a separate game object's aim based on the character aim? (But have some code controlling smoothness on the aim change, and rules as to when the aim of that game object's aim changes, etc)
     
  9. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    A possible solution would be to rotate the player towards an invisible gameObject. Then move this gameObject smoothly between targets.
     
  10. pherrera25

    pherrera25

    Joined:
    Mar 5, 2018
    Posts:
    11
    upload_2020-12-22_12-53-57.png

    In this situation on the above video, the camera didn't change because Kratos attacked the opponent on the left, and both opponents are in the frame already (if it's out of the frame, I think the camera would adjust more)
     
  11. pherrera25

    pherrera25

    Joined:
    Mar 5, 2018
    Posts:
    11
    This sounds good. So the follow object would be this invisible gameObject?

    Still with hard lock, but through code smoothly moving it.

    Sorry for so many questions and I really appreciate the help, I love this tool and there's so much I need to learn!
     
  12. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    If you are going with my suggestion of using 3rdPersonFollow, then the Follow target is the player (kratos). The player is rotated automatically to look at the invisible gameObject:
    player.transform.LookAt(target)


    I am happy to help, so keep the questions coming :D
     
  13. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    You can also try Transposer and Composer, where the Follow target is the player, and the LookAt target is a CinemachineTargetGroup. You would add and remove enemies from the TargetGroup. The player could always be in the TargetGroup, so the player is always visible. Smoothly adding and removing enemies will produce smooth motions. To add/remove targets smoothly simply play with their weights. That is, when adding an enemy set their weight to 0, then lerp it to 1. And when removing an enemy, lerp their weight to 0, then remove it.

    This will produce a different camera behaviour.
     
  14. pherrera25

    pherrera25

    Joined:
    Mar 5, 2018
    Posts:
    11
    If I continue with Hard Look At:

    I think for my project it will make more sense to do the other way around (With the invisible game object based on the character position/rotation being smoothly controlled by code) because sometimes I want to snap the player to facing before an attack (Like God of War 4) ... but not snap the camera.

    If I tried the Transposer and Composer, I'd lose this "Always over the shoulder" element, right?

    upload_2020-12-22_13-15-12.png
    upload_2020-12-22_13-15-37.png

    I am trying to keep the character in the overall same screen space position like the screenshots (even if your attack facing is different), which happens in god of war 4 (minus some special moves, etc)

    So probably 3rd person follow and modifying rotation of the empty gameObject is the way to go for this?
     
  15. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Yes.
     
  16. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Yes. Though, you do not need to rotate the invisible target gameobject. Only it's position is relevant. The third person vcam's Follow target's rotation is important. So you need to have the follow target look at the invisibile target gameobject. You can do this with this simple script attached to your follow target (player):
    Code (CSharp):
    1. public Transform invisibleTarget; // needs to be set in the editor
    2. void Update()
    3. {
    4.         transform.LookAt(invisibleTarget);
    5. }