Hi. I’ve recently implemented a “zoom and tilt” bit of functionality with Cinemachine using a position composer and pan/tilt composer. I may have done this incorrectly, or this functionality may exist out of the box, but I have it working more or less like I want:
- The user and engine can focus on a tracking target (a unit in the game, or dragging the isometric map around) and cinemachine will “blend” to that location smoothly (not an actual blend).
- User can zoom in/out with the mouse wheel, constrained to my settings.
- Pan/Tilt will automatically happen based on zoom - this was the hard part.
If I just set the Tilt Axis value, then the tilt snaps in a kind of jarring way (while the position is composed nicely). My solution was to do some trig and calculate the tilt angle based on the camera’s Y position (precalculating the min/max Y based on the min/max tilt constants).
Code here: using RuleOfCoolStudios.Utils.Unity;using System.Collections;using System.Co - Pastebin.com
Video here: https://youtu.be/-QLsSNbCurM
Better would be to calculate the current distance based on the Y position because Y position doesn’t interpolate smoothly (values near the top tilt the camera a bit too much).
Best would be to have the “current distance” of the PositionComposer be exposed as a member so I could just read that value and lerp/tilt accordingly.
Unless there’s a better way out of the box?