Search Unity

State Driven Machine for Unity2D not working

Discussion in 'Cinemachine' started by imposter_syndrom_incarnated, Sep 12, 2020.

  1. imposter_syndrom_incarnated

    imposter_syndrom_incarnated

    Joined:
    May 1, 2020
    Posts:
    51
    This problem arises when I use Unity 2019.2.8f1 Personal.
    I have worked on the same project on unity 2018.3.8f1 and 2017.3.1f1 versions and it works there.

    These are my cameras and all these virtual cameras do follow the player and the different Orthographic Sizes are captured by Unity as shown below


    But the problem is that the white camera in the screenshot (the original/first virtual camera made, from which the other camera for other animations have been duplicated) is the only one with the Orthographic Size that is shown during the game playing despite each camera having been assigned the animations and different Orthographic Sizes as you see in the screenshot below


    I wanted to see the game window guide for the additional cameras duplicated from the main virtual camera, but I can't see that either. I can't make any changes to their body in the Framing transposer mode. I can only see and work with the game window guide for the only camera shown during gaming mode:


    I cannot see it for any other cameras


    From what I have noticed, any 2D cameras that I create in the project, lacks have the features of the first virtual camera, even if I duplicate it. Only one virtual camera works as it should. no matter which one it is.

    The layer in the Inspector of the pictures above is ground because I had made different animation layers to implement the jump animation later. These are the states of relevance:

    while these are states of the jump, that I have not used in my player class yet, nor in the state driven camera


    I have seen other people working with state driven cameras by changing their Orthographic Size and Unity shows the change immediately in the game screen. However it is not the case for my additional cameras. They only move up and down in the scene but nothing changes in the game screen.

    I am not sure what the problem exactly is.
    Any help will be appreciated, thank you !
     
    Last edited: Sep 13, 2020
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Virtual cameras can be Live (meaning that they are currently controlling the Main Camera) or Standby (meaning that they are not currently controlling the main camera). Only Live vcams display the game view guides. The StateDrivenCamera uses the current animation state to decide which of its children should be Live.

    You can temporarily force a vcam to be Live by pressing its Solo button in the inspector:

    upload_2020-9-14_10-33-53.png
     
  3. imposter_syndrom_incarnated

    imposter_syndrom_incarnated

    Joined:
    May 1, 2020
    Posts:
    51
    Hello, I have tried doing what has been suggested, but the cameras are not changing the views despite the different animations on unity 2019. I have downloaded older versions of Unity, such as 2018.3.8f version, remade the project again there and it is working perfectly on the 2018 version and on Unity 2017 version. I was wondering what was different in the 2019 version of Unity for the State Driven Camera not to be working as expected
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    We are not aware of any changes done in 2019 that might affect this. Can you make a small test project that shows the problem and send it to me?
     
  5. imposter_syndrom_incarnated

    imposter_syndrom_incarnated

    Joined:
    May 1, 2020
    Posts:
    51
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Thanks for the upload. When packaging a unity project, you can safely delete the Library folder before zipping - it makes everything very very much smaller. A tip for next time :)

    When I open your project with Unity 2019.4.5f1, it reports an error in SimpleActivatorMenu.cs - but that is easy to fix by changing
    GUIText
    to
    UnityEngine.UI.Text
    . After I did that, the scene seemed to do what it's supposed to do: a virtual camera looking at an empty GameObject player, and tracking the player when it moves. Your setup looks correct. I don't understand what the problem is.

    Your original message said something about animation states, but there were no animation states in the project you sent.

    One thing to note about versions (sorry, I neglected to notice this in your original message):
    Cinemachine 2.3 and up only supports Unity 2018.4 and up.
    For Unity versions below 2018.4, you have to use Cinemachine 2.2.9.

    If you want to try zipping up your actual project, and supplying repro steps (very important), I would be happy to look at it. You can DM it to me privately if you like.
     
  7. imposter_syndrom_incarnated

    imposter_syndrom_incarnated

    Joined:
    May 1, 2020
    Posts:
    51
    Thank you so much for the tips! Very kind of you to check.
    The animations were in the Animations Folder inside Assets folder upload_2020-9-17_13-9-1.png
    I have also uploaded a new zip folder of the project without the library folder as you recommended.
    The version of Cinemachine I seem to have used is 2.6.2 for the project for Unity 2019.
    In the project I uploaded, the problem seems to be that despite having specified what views I wanted for the different animations, the view/Orthographic Size would not change during the game play.
    Thank you again for getting back to me!

     
    Last edited: Sep 17, 2020
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Thanks for the new upload. Can you tell me how to reproduce the problem? What scene do I open? What do I do once it's open? What do I look at?
     
  9. imposter_syndrom_incarnated

    imposter_syndrom_incarnated

    Joined:
    May 1, 2020
    Posts:
    51
    Sure!
    In the Asset folder there is the scene called 'FistInSecond'.
    In the same folder there is also the folder with the animations called Animation.
    These animations refer to the player, the prefab of which (called 'Player') is in the Premade folder, again inside the Assets folder, which contains the another prefab: the main camera and the state driven cameras with the children.

    If you could just test on Unity2019 that given various states/animations of the Player (in Premade folder) on the StateDrivenCamera, and differerent Orthographic Sizes of the lenses of each of the children cameras of the StateDrivenCamera, it works as it should during the game play, that would be great!
    upload_2020-9-17_14-40-0.png
    Thank you so much!
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    I found the problem.

    You have set the Animated Target to "Player", but somehow it's the wrong object.

    upload_2020-9-17_10-17-14.png

    Because, when I rename the correct object, the camera doesn't see it:

    upload_2020-9-17_10-18-45.png

    So I just dragged the real player in and it worked correctly.
     
  11. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    And here is a helpful debugging tip. If you select this option:

    upload_2020-9-17_10-21-12.png

    CM will show you what the current active camera child is:

    upload_2020-9-17_10-21-51.png

    (There is also a similar option in CM Brain)
     
  12. imposter_syndrom_incarnated

    imposter_syndrom_incarnated

    Joined:
    May 1, 2020
    Posts:
    51
    Thank you for all the help provided!!:D:D:D