Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Don't miss out on the Unite LA Keynote for the latest information from Unity! Set a reminder!
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Reusing virtual cameras and blending issues

Discussion in 'Cinemachine' started by Kurtney, Aug 9, 2018.

  1. Kurtney

    Kurtney

    Joined:
    Jul 24, 2017
    Posts:
    2
    Hi ! ,

    I'm working on a 3D turn based game, similar to XCOM.
    We can aim from every character of the player to every enemy that is visible, it's also posible to aim different body parts from each enemy.

    What I'm trying to do is to use a small pool of vcams and reuse them, when the player wants to go to aim mode I just set the vcam it should use (assigning body and aim settings with code) disable the current one and enable the new one, in that order. If the player switches the aim target I get another vcam from the pool and do the same. Of course, there is the blending process each time I swap them.

    The issue I have comes when I start reusing vcams that have been involved at some past point in the same blending. With this I mean that the player has been switching targets without letting the blend finish (the debug text displays "Whatever target vcam %, from mid blend", and all cameras that have been involved in that blend have their status at "live" even if they were disabled). I can see that when I start reusing the vcams there's some kind of teleporting going on the main camera.

    I have some workarounds in mind for this and already have tried to solve it with other ones with no success, (I'm trying to avoid to create dozens of cameras; for every character, for every aimed body part, using look target dummies, etc...).

    I've reached a point where I'm just curious about if I'm doing something wrong, or that is an expected behaviour (I really suspect its the case). Any help / explanation is appreciated.

    Thanks in advance ! :)
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,649
    As long as the vcam is live, it's driving the main camera, so if you make a sudden change to it, the main camera will pop. Vcams remain live while there is still an active blend taking input from them, even if the vcams are deactivated. Blends chain, so if you begin a blend while another one is in progress, you will end up with a 3-way blend, where all 3 vcams are feeding the main camera, and so on.

    I would suggest that before you decide to use a vcam in the pool, check if it's live and it it is, use the next one instead. If all the vcams in the pool are live, create a new one dynamically and add it to the pool. Have one common pool for everyone, not a whole bunch of little pools. The pool won't ever grow too big, unless your blend times are really long.
     
  3. Kurtney

    Kurtney

    Joined:
    Jul 24, 2017
    Posts:
    2
    Hi Gregoryl, thanks for the info and your suggestion. I considered that option but it means that in theory, the game would be easily breakable or unperformant if someone kept switching the aim target too much (it would probably never happen in practice). For the record, I finally went using one single vcam, with a dummy that gets teleported to each target point and another dummy which smooth-follows it and is the look target of the vcam. For the follow offset I will simply animate it too in case I need it.