Search Unity

How to make character face the same way free look camera

Discussion in 'Cinemachine' started by Bltzz13, Sep 10, 2017.

  1. Bltzz13

    Bltzz13

    Joined:
    Sep 10, 2017
    Posts:
    8
    Recently I started using Cinemamachine and I decided to switch my third person camera to cm FreeLook camera and I was wandering if there is a way to make my character face the same way as the free look camera when he is walking?
     
  2. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    Hi @Bltzz13 there's a section in Free Look just for that. Something to consider though, if you want the camera to face a certain direction, are you sure you want to be able to Free Look? If you don't want the user to have orbit controls, it's probably worth checking out the Orbital Transposer mode on a virtual camera body.

    If you do want orbit controls and to have the camera 'recenter' to a particular angle after they stop inputting:

    Setup your FL Heading Definition to be how you'd like. They all give different results.
    Position Delta is like a bread crumb kind of follow.
    Velocity is the direction of motion - think of a car powersliding - it's facing direction is not the same as the direction of travel.
    Target Forward is the direction your follow object is pointing - maybe try this one first
    World Forward gives you the ability to keep cameras oriented to your follow object in a world relative way. IE the camera is always 'south' of the character, etc.
    upload_2017-9-10_17-26-20.png
    Once you have that, check on Recenter To Target Heading and give it some numbers. Try 0,0

    Note you can tone down the Max Speed if you want to attenuate the inputs for just that shot.
    upload_2017-9-10_17-27-37.png


    Super important pro tip!
    With the State Driven Camera module, it's super easy to make lots of different free-look cameras and have them blend together based on animations. Don't try to make just a single free-look camera for your game, blend between lots of them based on game events or animations! 10+ free-look setups just for a character's localmotion system is not uncommon and it's super powerful!
     
  3. Bltzz13

    Bltzz13

    Joined:
    Sep 10, 2017
    Posts:
    8
    Firstly thanks for the quick response and the helpful tip but that's not exactly what I meant. What I meant was that when I rotate the mouse while my character is moving I want him to rotate with the rotation of the camera. Basically I want to make the camera and the character control like in The Last of us.
     
  4. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    Why not drive the character with the mouse/input and have the camera follow that?

    Or Input X drive the character and Input Y drive the freelook height. Turn off the freelook X input and have that go straight to the character only.

    Is that what you mean?
     
  5. Bltzz13

    Bltzz13

    Joined:
    Sep 10, 2017
    Posts:
    8
    Thank you, that might work, now I feel stupid that I didn't thought of it. Anyway I would totally try that and probably come back with more questions.
     
  6. Bltzz13

    Bltzz13

    Joined:
    Sep 10, 2017
    Posts:
    8
    Hello i have another question how can i add state to the state driven camera. Because it's not finding my animations. And i use animations from mixamo
     
  7. Bltzz13

    Bltzz13

    Joined:
    Sep 10, 2017
    Posts:
    8
    And also how can i use post processing fx on those cameras
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    @Bltzz13 For the SDC to find your animation states, you need to set its Animated target, and the layer. The state menus will then be populated with all the animation states present on that layer.

    upload_2017-9-15_11-11-3.png

    For PostProcessing, you need first of all to add the CinemachinePostFX behaviour to the CinemachineBrain. You can give it a default profile. Then, in each vcam where you want a different profile, add a CinemachinePostFX behaviour there also, and set the override profile.
     
    Last edited: Sep 16, 2017
  9. Bltzz13

    Bltzz13

    Joined:
    Sep 10, 2017
    Posts:
    8
    How can i add the occlusion culling effect to the SDC because from what i see it's only applied to the main camera
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    The SDC is not a camera. It's a virtual camera and its job is to tell the camera where to go. So just put occlusion culling on the Unity camera, and it will work when the camera is being driven by the SDC.
     
  11. Bltzz13

    Bltzz13

    Joined:
    Sep 10, 2017
    Posts:
    8
    Thank you, and I also wanted to ask if there is a way of setting default position for the free look camera for when the scene starts. Because when the scene starts the camera is looking at the side of my character. And I also got some error and i don't know why.
    error.png
     
  12. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    @Bltzz13 The FreeLook's XAxis.Value field sets the vantage point. Normally, the input system drives that. You can initialize its value from script when your camera starts up.

    The null reference errors are a known issue in CM 2.0, and have been fixed in CM 2.1. They are harmless.