Search Unity

state driven cinemachine and collision

Discussion in 'Cinemachine' started by eoniantech, Jan 8, 2021.

  1. eoniantech

    eoniantech

    Joined:
    Jul 1, 2014
    Posts:
    7
    Hi
    I started using cinemachine state driven which awesome to add some effect based on the player action but in some case (since it is a top down game) i would like the camera to go up or down to give a better view of a room the player enter depending of its size.

    I was thinking using collider that when the camera enter one specific collider it would switch to another cam that is a little higher or lower. But except if I missed something, state driven cinemachine is not designed to handle that.
    how should I do that?
     
    Last edited: Jan 10, 2021
  2. eoniantech

    eoniantech

    Joined:
    Jul 1, 2014
    Posts:
    7
    Update:
    I started to experiment with the CinemachineTriggerAction helper script which solve the problem of switching between 2 Vcam inside a state driven cinemachine. But I'm having a hard time figuring out what would be the best course of action (on object enter AND on object exit ) to use to be able to take the current camera and smoothly change its height back and forth when it enter a zone or exit it..
    I tried to use 2 timelines but they seems to play only once even if the On object enter is configure to play it from Start.
     
  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,717
    I would set up the CinemachineTriggerAction script to activate the top-down vcam on player enter, and deactivate it on player exit. That would automatically restore the vcam that was previously active. CinemachineBrain would take care of the smooth blending. You don't need to involve Timeline in this.
     
    Last edited: Jan 18, 2021
  4. eoniantech

    eoniantech

    Joined:
    Jul 1, 2014
    Posts:
    7
    Hey. thanks for the answer.

    I was able to solve my problem while still using a state driven camera. And now i can do pretty much whatever I want with the camera reacting to an animation being play. Which is pretty cool.


    I'm trying to do a cut scene now but I have a problem as despite using the collision detector script of cinemachine... when my camera end up behind a wall because of the position of the player.... well all you see is a wall. I selected all the layers to be Invisible to the camera inside the collision detector of cinemachine, but still I continue to see all the prefabs between the camera and the player targeted by it.

    Any Idea why?
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,717
    I'm not sure what you mean by this. Can you post an image of the CinemachineCollider inspector?