I am using Cinemachine 3.1.0 and a pretty basic StarterAsset environment. The Cinemachine camera is set up by default, so I assume it’s what the StartAssets want me to use. I have a first person view that seems to work just fine with movement, turning, jumping, etc and the StarterAssets set the Cinemachine camera with a Tracking Target of PlayerCameraRoot and a Position Control of Third Person Follow. Ok, great.
What I want to accomplish is using binoculars to zoom into objects in the environment and some of these objects have an event box around them that will kick off an event that will temporarily lock control and move the player’s view from one object to another while they are still zoomed in. Basically small scripted events that can occur when viewing something from a distance. I have the zoom working just fine using FOV adjustments and also I am able to acknowledge when one of these events should start by using a raycast and also checking the zoom level of the binoculars. No problems so far.
Now when kicking off this event I want multiple objects to be looked at via the event, like possibly switching the center of the view between two characters, objects, etc. I notice that the default StartAssets control the horizontal rotation of the player by rotating the transform but the vertical rotation is handled by changing the Cinemachine localrotation pitch:
// Update Cinemachine camera target pitch
CinemachineCameraTarget.transform.localRotation = Quaternion.Euler(_cinemachineTargetPitch, 0.0f, 0.0f);
// rotate the player left and right
transform.Rotate(Vector3.up * _rotationVelocity);
I’m not sure if I need to be concerned about that but I’m assuming that I can just use the Look At Target transform to move the player’s view to look at what I want. So I’m setting the Look At Target and then setting the Rotation Control to Rotation Composer and then setting the Damping to 3 for both the X and Y values. It kind of works, but the first target to look at results in the camera jerking toward it, but oddly subsequent targets don’t have the jerking motion and do move smoothly toward the target, although they never quite center on it, always being either a little to the left or right compared to what I’m trying to center on. Then when the camera control is given back to the player, the first input jerks the camera again and then it returns to normal.
Maybe I’m giving too much context, but basically I am trying to:
Move the camera target to multiple objects using the player’s zoomed in view, initially starting from where the player is already looking and then smoothly moving between multiple targets by switching Look At Target several times before returning control to the player with the same level of zoom that the event is currently at.
I did see things about having multiple cameras for Cinemachine but this seems like it isn’t needed here? Any help is appreciated, thanks!
