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.
  2. Dismiss Notice

Cinemachine follow Player but also focus on trajectory

Discussion in 'Cinemachine' started by iboshido, Apr 4, 2021.

  1. iboshido

    iboshido

    Joined:
    Mar 4, 2017
    Posts:
    33
    My Virutal Cinemachine Camera is following the Player in a 2D Platformer. The player can shoot arrows. I would like the Cinemachine Camera to look ahead where ever the trajectories are aiming, but i just dont know how to do it. The trajectory dots are objects i instantiate in runtime. I tried to switch the target from player to trajectory dots, but that was a mess. Can anyone help pls?


     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    You could have two vcams:
    1. Vcam 1 for when the player is not aiming. Something like what you have right now.
    2. Vcam 2, a similar vcam like vcam 1, but this one has the "trajectory" as the Follow target. If you'd like to frame the player and the aim location, then try using a TargetGroup.

    By default vcam 1 is active. When the player aims, you activate vcam 2.
    You can easily control the transition between the two vcams using the Blend settings (default blend, custom blends) on CMBrain.
     
  3. iboshido

    iboshido

    Joined:
    Mar 4, 2017
    Posts:
    33
    Thank you very much! it worked just as u said
     
    gaborkb likes this.
  4. iboshido

    iboshido

    Joined:
    Mar 4, 2017
    Posts:
    33
    Sorry but i have another problem, it might even be a bug. I just cant figure it out. Just as u sugested i use 2 vcams now. One is for when player is in idle state. The other one is when player is aiming. The problem i ve now is, that sometimes when i stop aiming before the idle vcam fully transsion to the aiming vcam, it just abruptly cuts back to the idle vcam. Even tho i use custom blend times. When i stop aiming after idle vcam reaches 100% of the transsion, the transsion back from aiming vcam to idle is smooth just as i want it. I hope i was able to make my case clear.


     
    Last edited: Apr 6, 2021
    gaborkb likes this.
  5. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Thank you for reporting it. A fix is going to be available in an upcoming patch.
     
    iboshido likes this.
  6. iboshido

    iboshido

    Joined:
    Mar 4, 2017
    Posts:
    33
    so basically when u interrupt a virtual camera while transitioning to another vcam, it abruptly cuts back to it self. Is there a work around to that?
     
    Last edited: Apr 10, 2021
  7. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Not exactly. It does not cut back to itself. Instead it takes the current blend time, and uses that to do the interrupt. I DM-ed you with a fix.