- Home /
The question is answered, right answer was accepted
CinemachineBrain component reference
So i want to disable the CinemachineBrain component on my third person camera whenever i pause for obvious reasons......but i can't seem to be able to reference it properly... whenever i try to do this.... else if(uimanager.pauseactive) { healthbarmanager.camsetting = "paused"; tpcam.GetComponent().enabled = false; } unity throws an error saying "The type or namespace name 'CinemachineBrain' could not be found".......is there a special using directive for cinemachine im missing? Thanks in advance!
Answer by Anonymous620 · Jul 06, 2021 at 11:47 AM
using Cinemachine;
private CinemachineBrain brain;
void Start()
{
brain = this.gameObject.GetComponent<CinemachineBrain>();
brain.enabled = false;
}
thanks man, that using directive is exactly what i was looking for...there's some $$anonymous$$or issues with the camera position on disabling the brain....but the main issue is solved...
ok new problem.....i can't seem to get the position of the camera right
void DisableTPBrain()
{
Vector3 campos = tpcam.GetComponent<Transform>().position;
Quaternion camrotation = tpcam.GetComponent<Transform>().rotation;
tpcam.GetComponent<CinemachineBrain>().enabled = false;
tpcam.GetComponent<Transform>().position = campos;
tpcam.GetComponent<Transform>().rotation = camrotation;
}
Im using this to set the position and rotation but it is not working...i can only assume that it's because the real position of the camera is not what cinemachine uses....any advice?
Follow this Question
Related Questions
C# Camera.main.GetComponent: Unknown Word SmoothFollow 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Networked Game Issues - Camera does not follow script 1 Answer
My object is not reappearing 1 Answer