Search Unity

How to create a 3rd person shooter camera, similar to Battlefront 2.

Discussion in 'Cinemachine' started by DigitalAdam, Feb 9, 2018.

  1. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,209
    I'm playing around with Cinemachine, and I'm trying to get something similar to the 3rd person shooter perspective like Battefront 2. Here is the example I'm going for. I'm not too concerned about the zooming aspect, more of just the camera motion when following the player and shooting. Is this possible with Cinemachine?
     
  2. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    HI @adamz

    Yeah that's absolutely doable in CM. There's number of things going on with the Battlefront camera, here's a brief list.

    - Default orbit camera when running
    - Pushed-in aim camera when in targeting mode
    - Impulses / recoils / camera shakes
    - Collision system

    Outside of the impulse/shakes (coming soon!), CM can definitely do the rest. We've built modules specifically for these problems and this game genre.

    Have a look at the example scenes in the latest CM on the Asset Store. There's examples for free-look, collisions and State Drive Cameras - a way to trigger different camera behaviours based on animations. You can blend to the pushed-in targeting camera as simply as putting the aim animation into the CM State Driven Camera module and calling a pushed-in version of the free-look

    3rd person action / shooters are actually my favourite camera class. I've been lucky enough to make them for a few games and am happy to share more info and challenges on this topic... like... Hey, are you shooting from the weapon or the centre of the screen?

    Keep us posted.
     
    wcoastsands likes this.
  3. Duusty

    Duusty

    Joined:
    May 14, 2013
    Posts:
    56
    i would like to add some questions to this topic if its okay four you @Adam_Myhill and @adamz for the type of Camera Rig mentioned.

    In terms of responsiveness, would it be best to make the camera depend on the character rotation or the other way around?, to rotate the character to the target/forward direction of the camera.

    And if thats the case what would be the best way to make the pistol still aim/direct at the crosshair in the center of the screen, even if the character is slightly off (like in the mentioned video / overshould like)




    Also i think the collision avoidance for the camera used in battlefront 2 is slightly different then the one shipped with cinemachine if im correct





    Also Adam i see the camera in the video of battlefront, changing shoulders dependening on how much space between the camera and a collider is? Do you have a clue how this could be setup with cinemachine?
     
    Last edited: Feb 20, 2018
  4. Duusty

    Duusty

    Joined:
    May 14, 2013
    Posts:
    56
  5. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    Hi, please forgive the delay, @TehReason things have been hectic.

    Rotations - depends on how you plan to do inputs. Sometimes one analog does character movement and the other camera, in a controller type setup. Otherwise I'd suggest having the camera recenter on the character direction - we've built our Freelook 'Recenter to Target Heading' functionality specifically for that, with controls to recenter based on character direction, velocity, or be world relative.

    Aiming at the screen is also a really setup dependent one, depending on things like the above and if you have things like sniper scopes, compositional changes when using weapons.. etc. etc. Often the bullet magically comes from the camera Z right down to the center of the screen.. not from the player's weapon, but this has issues too if your character or camera can be behind a wall when the other one isn't.

    The collision avoidance is most certainly different for BF than ours. I actually designed the camera system in Frostbite years ago, so maybe there's some of my old stuff in there! I'm not sure what's in BF now so I can't comment directly. I can say the collision system in Cinemachine now is super powerful and the best I've ever worked with - huge props to Gregory for that. Let us know if you see room for improvement there.

    The BF shoulder change mechanic is cool. There's a few ways to do that in CM. If the player has unique animations based on wall awareness, then you can use the State Driven Camera to link those animations with over the shoulder left/right cameras. Or you could write a script which simply turns either the left or right versions of your freelook on when the character is in that state.

    Remember, never try to make one virtual camera do all the work, instead make lots of virtual cameras for different scenarios and turn them on and off as needed. I had 20+ Freelook cameras just for a character local motion and combat system once! It was awesome! When an enemy came near, the Freelook changed slightly, when 5+ enemies came, it pulled back farther, sprinting, jumping, low health, targeting - all of those anims and events seamlessly blended to a new Freelook. Super control.
     
    wcoastsands likes this.
  6. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
  7. Aldous00

    Aldous00

    Joined:
    Feb 11, 2017
    Posts:
    1
     
  8. ghanshyambista7

    ghanshyambista7

    Joined:
    Mar 30, 2020
    Posts:
    5
    Does AnyBody Have Idea About Ads Aiming System Like Pubg using Cinemachine Virtual cam ?
     
  9. dannyjace

    dannyjace

    Joined:
    Jun 7, 2020
    Posts:
    5
    Hey Adam, I'm making a third person controller right now and am using all free look cams for my different states (crouching, aiming, etc.), but when my character aims, the camera defaults to be looking up? Like it will start in the bottom rig and look to the sky when activated. I also have inherit position turned on. Is there anyway to have this aiming camera face perfectly forward on activation? As far as I can tell this is the only problem I'm having, but it's a major one.
     
    Last edited: Nov 24, 2020
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Have you looked at the new 3rdPerson CM components? Much better than FreeLook (and simpler). Have a look at the AimingRig samples scene that ships with Cinemachine.
     
  11. dannyjace

    dannyjace

    Joined:
    Jun 7, 2020
    Posts:
    5
    Thanks, I'll take a look!