vCam1 is looking at the map from some high position. (Look At = None or Ground)
vCam2 is looking at the Player from the same position (Look At = Player)
vCam3 is looking at the Player behind the Player. (Look At = Player)
And I want to change camera view : vCam1 → vCam2 → vCam3 If I click “change” button.
But Switching Camera view is not natural. (
)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;
public class PrioritySetting : MonoBehaviour
{
public CinemachineVirtualCamera vCam1, vCam2, vCam3;
public float time = 2.0f;
public void GoToVCam3()
{
vCam3.Priority = 12;
}
public void SwitchCamera()
{
vCam2.Priority = 11;
Invoke("GoToVCam3", time);
}
public void RollBack()
{
vCam1.Priority = 10;
vCam2.Priority = 9;
vCam3.Priority = 9;
}
}
I want to move the camera naturally while looking at the player at the same time.
It feels like this ↓
-------------------- Time Line ------------------>
vCam1 → vCam2 → vCam3 (X)
vCam1 → vCam2 vCam2 → vCam3 at the same time.
Also I want to turn the camera exactly the opposite path If I click “rollback” button.
vCam3 → vCam2
vCam2 → vCam1 at the same time.
I don’t want to use Dolly Track because the player can be anywhere.
It would be great if you help me on this problem.
Thank you.
If both cameras have the same LookAt target, the camera will continue to look at it during a blend. If the targets differ, then the LookAt point will blend from one position to the other. If one of the cameras has no LookAt target, then only a slerp is possible from one rotation to the other, and that rarely gives natural results.
So, to get maximal control, you should set LookAt targets to all your cameras. Also, you can control how the LookAt point blends using this setting on the cameras:
For the overlapped blending, have you tried using a timeline? Put a Cinemachine track on a timeline, create ovlerlapping clips for the 3 camera in a linear fashion. The length of the overlap controls the blend time. Then you can just play the timeline whenever you want.
Thank you for your answer.
But I wanted to create an object on runtime, and my camera have to see object, so I gave the example above.
Therefore, if I press the rollback button, I want to cinemacine’s Look At = Ground.
Also, Can I create a timeline and a cinema machine on runtime?
You can create the timeline asset in advance, and bind to the objects at runtime.
Another possible solution is to use CinemachineMixingCamera. That gives you precise control of a continuous blend of up to 8 cameras. You would have to drive their weights manually, perhaps using animation curves.
FYI it is also possible to set all the vcams to the same priority, then do vcam.MoveToTopOfPrioritySubqueue() for the vcam that you want to activate. It might not be appropriate for your setup, but it is there if you need it.