- Home /
How to create a panning, rotating camera with Cinemachine Freelook camera?
I'm making a map editor where you can place objects at different places on the map. I'm using Cinemachine Freelook camera, as it allows me to zoom in and out, and rotate around a point.
However, I'm not sure how I would get it also panning across, so if I want to place an object elsewhere, I can click and drag the screen left/right/up/down and it'll pan to that location.
I've tried:
creating a gameobject which the cinemachine camera both "looksAt" and "follows" (by setting the respective props on the camera), and then translating the gameobject's location to move the camera around, keeping the target object in the center of the screen, which does achieve the panning effect I want, however, it results in a weird rotating issue, where as you pan across (left or right) the camera also curves around as well. So it doesn't give a standard pan from one side of the map to the other. It's a bit hard to describe though.
also tried instead of changing the target object's location, I add a cinemachine offset script to the camera, and then I adjust the x/y/z to that, and it achieves the panning effect exactly how I expect it to work. However, then when I rotate, because the target gameobject is still in the original place, it doesn't rotate around the center of the screen as I would expect.
I expected having a panning, rotating camera would be easy and fairly standard to do in cinemachine, so perhaps I'm missing something very obvious.
cheers