I want to get a smooth transition from object A to B, but only if, the object B is outside vcam's dead zone. Vcam should look at the object with static rotation. (only the camera position should change)
I assume that I have to use:
Follow property - because it only affects vcam transform
Framing Transposer - to use dead zones in body component
I've tried spawning new vcam with B and disabled the first vcam - this gives smooth transition between cameras, but it does it always, even if A and B are inside dead zones of 1st and 2nd vcam.
How can I achieve smooth camera transition between 2 game objects only if the new one is outside the dead zone of previous vcam?
I know that I can do it by moving object followed by vcam from A to B and this should work with dead zones, but I'm looking for cleaner solution if it's possible
Description how to achieve what I described in a question is provided by Unity staff member - Gregoryl.
CM doesn't give you a notification when things go in and out of dead zones.
You can accomplish what you're looking for by polling the position of B relative to the camera and manually calculating whether the angle between CameraPosToB and CameraForward is sufficiently large, and activating the second vcam when it is.
Here is a part of code - doing what he described:
var angleToPlayer = Vector3.Angle(mainCamera.transform.forward, (player.transform.position - mainCamera.transform.position).normalized);
if (angleToPlayer > 20f)
{
cameraWatchingPlayer.enabled = false;
Destroy(cameraWatchingPlayer.gameObject, 3f);
InstantiateCamera(posX, posZ, player.transform);
}