Search Unity

Move cinemachine 2d by touching

Discussion in 'Cinemachine' started by Kennir, Jun 15, 2020.

  1. Kennir

    Kennir

    Joined:
    Oct 14, 2016
    Posts:
    6
    Hi dear all.

    I'm making a 2d game, The main virtual camera will follow the player in a normal state, The second camera should follow the gesture when the player touches the screen.

    My question is how to make the second camera? current I add a game object and set the second camera to follow it, set the damping is zero, When the player touches the screen, I move the game object by touch pointer, is it a best practice?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    It's a good way. Without knowing more details it's hard to say whether it's the best way.
     
  3. Kennir

    Kennir

    Joined:
    Oct 14, 2016
    Posts:
    6
    @Gregoryl Thanks for the reply
    I want the second camera should follow the finger movement, there is a polygon collider 2d to limit the movement range of the camera (The second camera attached confiner extension), so I think I can not edit the position of the camera directly, Can I use preset freelook camera? Does it look like made for fps games?
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    FreeLook is not the best choice for FPS games.

    You can edit the position of the camera directly if you turn off the procedural positioning by selecting "DoNothing" in Aim and Body. If you keep the procedural positioning, then you can only modify the vcam's position by modifying the target that it's tracking. It's your choice how you want to set it up.
     
  5. Kennir

    Kennir

    Joined:
    Oct 14, 2016
    Posts:
    6
    If I edit the position of the camera directly, will confiner still work?
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Yes - but the final camera position will not match the vcam's transform while the confiner is intervening. Vcam transform will represent the "desired" (i.e unconfined) position, confiner will add a delta to it for the vcam state.
     
  7. Kennir

    Kennir

    Joined:
    Oct 14, 2016
    Posts:
    6
    @Gregoryl I get it, Thank you very much!