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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Google Maps-like camera control

Discussion in 'Cinemachine' started by klicpjan, May 4, 2020.

  1. klicpjan

    klicpjan

    Joined:
    Oct 2, 2019
    Posts:
    4
    Hello, I would like to implement a camera control system similar to google maps - moving the camera smoothly by dragging the mouse and zooming using the scroll wheel. I have tried out a bunch of different ideas - moving the camera directly, moving an object which the camera would follow, but I still feel like I am missing something. When I move the camera directly I am unable to apply smooth damping, when I move the object I am unable to smoothly zoom in/zoom out due to the set follow offset of the Transposer. What would be the best way to approach this? The camera is in 3D space and is tilted by 45° along the x axis (we are using 2D billboards in a 3D space). Many thanks!
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,268
    I would move an object and let the vcam do the damping.

    You could make a complex object: the root (on the ground) which gets moved when you drag, and a child object representing where you want the camera to be relative to the root. Use the child object as a follow target. When you drag, move the root. When you zoom, adjust the distance between child and root. You never need to adjust the transposer offset.
     
    chopin1998 and klicpjan like this.
  3. klicpjan

    klicpjan

    Joined:
    Oct 2, 2019
    Posts:
    4
    Thank you for the lightning-fast reply! Your suggestion works really well, many thanks.