Search Unity

Deubt ClearShot - Virtual Cameras

Discussion in 'Cinemachine' started by CatrinMariachi, Jul 12, 2018.

  1. CatrinMariachi

    CatrinMariachi

    Joined:
    Nov 24, 2015
    Posts:
    20
    Hi, I combined CineMachine ClearShot with a couple of colliders and "vcam.gameObject.SetActive (true)" to use fixed cameras with the power of CineMachine.



    All virtual cameras are deactivated until the player enters his "vision zone" (OnTriggerEnter).
    I did read somewhere (The documentation maybe? i dont remember) that virtual cameras are always "active" searching for the "Look at" target.
    And that's where I have a doubt:
    Having all virtual cameras disabled at the start, does have a negative impact on performance?
    I do not know, maybe some significant delay in the damping (I haven't seen any delay or bug so far) for not being able to follow the objective

    I had been thinking about using SetPriority instead of Set.Active.

    But the way it works right now, i think is better, clearer and cleaner. But I have this question of whether having the cameras "disabled" has any cost in the performance of virtual cameras.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    So, if I understand correctly, you have the ClearShot children disabled, and you enable them only when the target enters the trigger zones that you have set up on each child camera. Is that right? If so, when a vcam is enabled this way, do you disable the other ones? If so, then I have to ask: what is ClearShot doing for you?

    From a performance perspective, if the vcams are active (but not live) then they are continually monitoring their target, to assess the quality of the shot. This does not come for free, and raycasts are involved. Deactivating them stops this from happening, and will actually improve your performance. However, if you're activating the vcams manually, then you are doing the job of the ClearShot yourself, so why bother with the ClearShot?

    Or maybe your scripts are activating in a crude way, and ClearShot is refining? But if so, when to the vcams get disabled again?

    Performance-wise, CM 2.2.0 has the new "Standby Update" feature, which significantly reduces the performance cost of having the children live if you set it to Round-Robin (which it is by default).

    Don't worry about the damping if the vcams are woken from a sleep state - they will behave properly.

    Have I answered your question?
     
    CatrinMariachi likes this.
  3. CatrinMariachi

    CatrinMariachi

    Joined:
    Nov 24, 2015
    Posts:
    20
    Yes, when the player leaves trigger zones the vcam of that area is deactivated

    Code (CSharp):
    1. void OnTriggerExit(Collider hit)
    2.     {
    3.         if (hit.tag == "Player")
    4.         {
    5.             vcam.gameObject.SetActive(false);
    6.         }
    7.     }
    8.  
    for some reason, if i do this without clearshot, the transitions get messy and sometimes vcams get upside down ((it has happened several times but I can not reproduce the error)
    And it is also easier to keep track of the cameras. Having the Vcam as childs of the clearshot makes it clearer to me to know what is happening and how to order future cameras. I just have to press the + button to add a new vcam and since Clearshot is already in charge of "Look at", I do not need to specify to each new camera what they have to look at. In case I want a fixed camera, I just have to put that specific camera, do nothing in the aim.

    Yea I tried Clearshot with Standby and Round-Robin, but sometimes cameras behaved strangely, they moved or the player was partially out of their vision zone and they did not change to another camera until the player left his vision completely, which does not help too much for what I try to do (a classic survival horror cam system), that's why I decided to use Box Colliders.

    You actually answered my question, Thank you very much!.
     
    Last edited: Jul 12, 2018