Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Change Body From 3rd person follow to HardLocktoTarget from script

Discussion in 'Cinemachine' started by Joyal_RedDevil, Feb 22, 2022.

  1. Joyal_RedDevil

    Joyal_RedDevil

    Joined:
    Feb 16, 2022
    Posts:
    3
    Hi i am using the cinemachinevirtual camera for following my character but i would like to change the body which i can set on the editor currently its set to 3rd person follow i want to change it to hardlock to target on rutime so that i can switch between first person and third person view . But currently i am not able to acess the body or change that from acessing CinemachineVirtualCamera script attached to the virtual camera . Is there any way to change this runtime
     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    You can use
    Code (CSharp):
    1. vcam.AddCinemachineComponent<CinemachineHardLockToTarget>();
    AddCinemachineComponent will remove any existing component at the same stage. In your case, you are adding a Body component.

    A better solution is to have two vcams: one first person and one third person view. Then, when you want to switch between them you can enable/disable them. This is better than using AddCinemachineComponent, because:
    • you have easy control over how the switch happens with Blend settings,
    • you can easily fine-tune your vcams,
    • it is faster than adding/removing components.
     
    antoinecharton and Gregoryl like this.
  3. Joyal_RedDevil

    Joyal_RedDevil

    Joined:
    Feb 16, 2022
    Posts:
    3
    Thanks for the help