1
  • 3d game
  • 2 game objects: A and B. (both spawned on runtime)

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

sswwqqaa
  • 1,545
  • 3
  • 15
  • 29
  • did you try the follow property of the virtual camera, it seems not linked to the actual unity camera – Paltoquet Nov 06 '19 at 14:42
  • Yes, I've tried. Follow with transposer and follow with framing transposer, but with no luck. (Same as 2nd scenario) – sswwqqaa Nov 06 '19 at 17:52

1 Answers1

1

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);
}
sswwqqaa
  • 1,545
  • 3
  • 15
  • 29