Search Unity

How to make a point of interest for cinemachine camera in runtime

Discussion in 'Cinemachine' started by Pourya-MDP, Nov 15, 2020.

  1. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    145
    Hey there
    I wonder how can i add a point of interest to the current virtual camera when i enter on a trigger
    The scenario is very straightforward
    I have freelook camera in my scene,it will track my character and everything is fine
    But now i have a door and i want the camera have a little bit of shift to the door whenever im in a trigger
    Something like telling the player that theres something you have to do with this door now
    (If the character is inside trigger then dont lose the door and keep it in the frame alongside character)
     
    Last edited: Nov 15, 2020
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Hi
    You can achieve that using TargetGroup. When you enter the trigger zone, add the door to your target group with a smaller weight than the player.
    Have a look at the CameraMagnets example scene. This example has useful scripts that will trigger the interest point (magnet) based on proximity.
     
    Pourya-MDP likes this.
  3. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    145
    Hey i already achieved it with exactly targetgroups but a bit diffrenet than your method
    I added character and a transform as the second one for target group
    Then parented the transform to player and in triggers i unparent the transform and lerp its position to the position of door
    This way the camera will follow the transform smoothely and when i exit triger i just make it a child of chatacter again and make its position to character.