Change Body From 3rd person follow to HardLocktoTarget from script

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

You can use


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.

Thanks for the help