Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

CM v2.1 Release Candidate

Discussion in 'Cinemachine' started by Adam_Myhill, Sep 24, 2017.

  1. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    Just noticed that removing "Default" from camera culling mask list "kills" CM brain, Is that a bug?


    (No Live Camera transform even thought i have like 10 vCams in the scene, adding "Default" to the culling mask list fixes the problem)

    Should i just create "CM" culling mask for all of my vCams?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
    The brain will only see those vcams that are on layers that the associated Unity camera can see. This is to allow you to have multiple brains in the scene (for situations such as split-screen) and channel different vcams to different brains, using the layering mechanism.

    In your case, it's likely that the vcams were all on the default layer. Unchecking that layer in the brain effectively hides your vcams from it.

    You don't need to create a special layer for your vcams, but you can if you like.
     
    JakubSmaga likes this.
  3. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,303
    I'm still getting pretty bad jerky movement on iOS. Going to try RC4 and check the difference
     
  4. caeyzer

    caeyzer

    Joined:
    Jan 18, 2015
    Posts:
    1
    I had some errors ("Assertion failed: Screen position out of view frustum...") while using 2.0.1 with a 2D Orthographic camera (I believe it was because it was automatically setting the camera size to 0). I just tried 2.1 RC6, and it now works perfectly with the Framing Transposer!

    I'm still discovering the whole suite, but from what I've seen already, it is absolutely incredible. Thanks a lot to everyone involved in the project !
     
    Adam_Myhill likes this.
  5. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,303
    Something strange happening with rigidbodies and 2017.2. Setting the update to "Smart" with a rigidbody as a composer/transposer target, and "interpolation" = true, the camera is very jerky. If I set the composer/transposer target to a normal Transform, set the update to Late, and make the target follow the rigidybody, camera is smooth. However, the interpolated rigidbody appears jerky. If I set to FixedUpdate and follow the body, everything is jerky.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
    What happens if you use SmartUpdate, and turn off interpolation on the RigidBody?
     
  7. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,303
    Testing now. Another strange thing that has started occurring with Smart Update:

    When the smart update type switches from Fixed to Late, or vice versa. The Game camera just hard stops, then resumes following sometime after. The other camera is a group composer, and contains objects in the group that may/may not have rigidbodies, and may/may not have interpolated rigidbodies. There is also a parent mixing camera that the "Game" and "Group" cameras belong to. This mixing camera controls weights between these two cameras based on the amount of active targets in the group. 0 targets = weighted towards game. > 1 targets = weighted towards group

    It's not possible for me to show game footage just yet, I'll try and replicate with a dummy project.

    I dunno, ever since I updated to RC6 and 2017.2. Lots of strange things occurring. Maybe to coincide with Stranger Things season 2 ;)
     
    Adam_Myhill likes this.
  8. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,303
    Ok, turning off interpolation and setting to Smart Update makes camera and player smooth again :D

    Thanks
     
    Adam_Myhill likes this.
  9. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,303
    So I'm seeing inconsistency between the Mixing Camera update and the Game Camera update mode.
    When they're different, the game camera doesn't follow the target.

    My Mixing Camera is showing "Fixed Update"
    Game Camera is showing "Late Update"

    Game Camera resumes following when it becomes "Fixed Update"
     
  10. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,303
    Sorry for the noise. Found the issue with the game camera not moving. The target group update mode was set to "Late Update". Setting to "Fixed" solves the issue. I've attached a repo project in case you want to see.

    Click "Toggle Weights" once to set group camera active. Notice choppy movement. Click again to return to Game Camera. Notice the camera will stop briefly before resuming.

    Maybe add a smart update on the Target Group? ;)
     

    Attached Files:

  11. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
    1. Why is your mixing camera showing Fixed Update? Did you set LookAt or Follow targets for it? Are you animating its transform?

    2. Why is your Game camera changing update modes?
     
  12. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
    For posterity, and because people seem confused about this whole update thing, I'm going to ramble on a little about it.

    Managing animations with the 2 distinct Unity clocks (frame clock and physics clock) is a tricky business, and not all combinations can be handled gracefully. SmartUpdate does what it can, but you have to pay attention to what gets updated when.

    Rule #1: the camera needs to be updated (i.e. moved and aimed) on the same clock as the thing it's looking at and/or following. If there is a mismatch, you will get judder.

    Smart Update helps to fulfill this rule by trying to determine on what clock the target is being animated (it does this by keeping track of transforms and checking whether they've changed). It then updates the vcam on the same clock as the target.

    But wait, you say. There are 2 targets: LookAt and Follow. That creates some potential problems that cannot be solved by SmartUpdate:
    • If the thing it's following is not on the same clock at the thing it's looking at, you have a problem.
    • If the thing it's looking at is a group, and the members are not all on the same clock as the group's update, you have a problem. The Group's update method is a setting in the group's inspector.
    • If the vcam's transform itself is being animated (without a Follow target) either through game logic, or animation, or parenting, and the clock doesn't match the target's clock, you have a problem.
    • SmartUpdate will only look at one target. First it tries the LookAt. If none, it uses the Follow. If none, then the vcam's transform itself is tracked.
    Rigid Bodies are animated on the physics clock. What does Interpolation do? It adds, after Update, a "little something" to the transform (which is not pushed back to the physics system), to improve the chances of it appearing to be smooth when rendered on the other clock. For the vcam, this looks like an object being animated on BOTH clocks. What to do? Its best option is LateUpdate, so that's what it does. It isn't always perfect.
     
  13. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
    That's probably a good idea.
     
  14. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,303
    I'm not animating it, mixing camera has no look or follow targets. I'm not changing game camera update modes.
    I believe the issue is with the Target Group, which had its Update mode set to "Late". So:
    • Mixing Camera contains 2 child cameras (game and group composer)
    • Game follows rigidbody
    • Group composer follows "CinemachineTargetGroup"
    • group update set to "Late"
    • Brain set to "Smart"
    So what I think is happening, is when the group composers mixing weight becomes dominant, the Mixing camera is updating as "Late", because of the target group. Then, the game camera becomes dominant, which wants to be Fixed Updated. The Mixing camera get's a little funky and stalls the game camera. Here's a video:
     

    Attached Files:

  15. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
    hmmm... interesting. Let me have a closer look at this tomorrow. Thanks for posting the repro project, it's much appreciated
     
  16. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    464
    @Gregoryl can you add ability to set limits on camera rotation, please? Also, which behavior to choose when using POV camera with character controller: set camera rotation in two axes and controller movement direction based on camera direction or set camera and character direction separatly and move character only in forward axis? And if using the second option how can i use the same smoothing math for character rotation which used in the POV camera for consistency between character and camera rotations?
     
  17. keithkld

    keithkld

    Joined:
    May 14, 2015
    Posts:
    4
    The Confiner works great to accomplish the following:

    The subject moves in from the right to left of the set and the vcam pans to frame it (Aim).
    When the subject is closer to the center of the set, and is in profile, the confiner allows the vcam to dolly as well (Body and Aim).
    When the subject moves into the left side of the set the vcam only pans (Aim).

    This is what I was looking for!

    But, the damping on the Confiner works strangely in this case. A dolly operator would ramp up and down as it neared the ends of the move. What would be needed is something that dampens the dolly, but doesn't cause it to move back in the other direction.
     
  18. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
    @keithkld Yes damping on the confiner is weird and probably useless. I suggest you just turn it off. Unfortunately the damping style that you would like to have is non-trivial to implement, so will not be coming in the form of a quick-fix.
     
    Last edited: Oct 24, 2017
  19. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
    I'm not sure I completely understand your questions.
    Rotation limits: Are you talking about the POV aim component of the vcam?
    Which behaviour: that depends on what camera behaviour you would like to have. It's a personal preference. You'll have to describe more specifically what kind of behaviour you're looking for.
    Smoothing math: if your character forward locks to the camera forward then the smoothing math will necessarily be identical.
     
  20. keithkld

    keithkld

    Joined:
    May 14, 2015
    Posts:
    4



    Thats what I thought but thanks. Please keep it on your radar because the concept of pan more here and dolly more there is much easier with the Confiner.

    My alternative was setting up zones with different cameras, and triggers. Using the Confiner works better and is much more intuitive.
     
  21. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
    @CDF thank you very much for this post. It isolated an error in the handling of vcam updates in mixed-clock environments. I'll include a fix in the next RC.
     
  22. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,303
    Awesome :D
     
  23. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    464
    @Gregoryl yes, in POV component. Actually, i think, limits in composer aim would be usefull too. I want to implement "lock on enemy" feature and if enemy is too high i dont want to rotate the aim camera more than maximum rotation in POV camera.
     
  24. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
    @Onigiri You can accomplish this quite easily with a custom extension, for example the one attached here. Just drop this script in your project and it will be available in the Extensions dropdown of the vcam inspector.
     

    Attached Files:

    Onigiri likes this.
  25. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    464
    Ah, i see. Thank you very much.
     
  26. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
    RC7 is now available for download.
    Release Notes:
    • StateDrivenCamera: transition at the start of animation transitions, not the end
    • bugfix: camera was sometimes freezing for a few seconds in mixed-clock environments
    • Transposer damping bugfix: always use camera-offset space for damping
    • Confiner: added support for CompositeCollider2D for tilemap bounds auto-generation
    • SimpleFollow renamed to SimpleFollowWithWorldUp, for clarity
    • Added Y damping to SimpleFollowWithWorldUp
     
    CDF and JakubSmaga like this.
  27. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    2017.3 Beta, RC7, Performance always goes low after few seconds/minutes because of CM Brain.

    I've waited 10 minutes, then enabled CM Brain. (You can see the spike, At the start everything was normal)



    Update: Found out that disabling StateDrivenCamera fixes this, enabling it still gives that lag thought. Is that a known issue?

    Update 2:



    (It might be a 2017.3 bug though, I can downgrade to 2017.2 to check if I still would have this problem)
     
    Last edited: Nov 2, 2017
  28. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    464
    I would like to see camera type that can inherite and override properties from another camera. Imagine situation when i have POV camera and i want to make different states(idle, walking, running states with different noise settings). With that type of camera i can inherit rotation of POV camera and blend only noise settings. Also, would be cool to see bobbing settings asset with similar to noise settings properties, like amplitude and frequency, but without randomness.
     
  29. Emile-Swain

    Emile-Swain

    Joined:
    Jun 23, 2015
    Posts:
    35
    Hey, Loving the Latest release. I couldn't find a feature to allow me to set a Cinemachines Path waypoint to the position of the scene camera. I wanted to quickly compose the path by flying around in the scene, adding waypoints along the way. So i added a button into the CineMachinePathEditor.cs.

    I was wondering if there was an existing way to do this?

    Code (CSharp):
    1. EditorGUILayout.BeginVertical();
    2.             if (Target.m_Waypoints.Length > 0) {
    3.                 if (GUI.Button(rect, new GUIContent("Set waypoint to camera position.")))
    4.                 {
    5.                     //SceneView.currentDrawingSceneView.camera
    6.                     CinemachinePath.Waypoint wp = Target.m_Waypoints[mWaypointList.index];
    7.                     Vector3 pos = SceneView.lastActiveSceneView.camera.transform.position;
    8.                     wp.position = Target.transform.InverseTransformPoint(pos);
    9.                     Target.m_Waypoints[mWaypointList.index] = wp;
    10.                 }
    11.             }
    12.             EditorGUILayout.EndVertical();
     
  30. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    464
    Why is negative dutch clamped to -179 instead of -180?
     
  31. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
    @JacobSmaga Thanks very much for this post. I did find a recently-introduced GC-alloc problem in FreeLook. Is it possible that your state-driven-camera had some FreeLooks in it? That would explain why disabling it makes the problem go away. Can you try dropping this patch into your project (replace the existing file of the same name) to see if that fixes your issue?
     

    Attached Files:

  32. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
    No good reason. Nice catch. :)
     
  33. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
    What a great idea! Thanks for this.
     
  34. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
    While the inheriting thing is a good idea, the architecture at present won't allow it. You'll have to duplicate the vcam and tweak the copy for now.
    I think the bobbing is something that should be implemented as a CinemachineExtension. That way, it can be combined with noise, and multiple such extensions would have an additive effect.
     
  35. Emile-Swain

    Emile-Swain

    Joined:
    Jun 23, 2015
    Posts:
    35
    No problem. I had written a path thing for the previous cinemachine so had a clear idea of what i wanted to achieve.

    I was also looking to add a button to automatically set the height of a waypoint above the surface below it. Basically a button on the waypoint that casts a ray downwards(which ever way downwards is for you & your environment) and positions the waypoint accordingly above the hit surface.

    This way the waypoints can more or less track the topology of the landscape. I'm thinking that this would be better as an additional script that can access the waypoints, rather than adding it to the existing script. If i write it, i'll share it.
     
    Gregoryl likes this.
  36. fabioColombini

    fabioColombini

    Joined:
    Dec 9, 2013
    Posts:
    30
    Hi, where can I find how to use "Confiner" with 2D ?
    I´ve tried here, but I can´t get it working.
    I want to block the camera to not exceed a boundary.
     
  37. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
    @fabioColombini In the inspector for the virtual camera, you will find an "extensions" dropdown. Use it to create the Confiner.

    upload_2017-10-30_13-11-11.png

    Next, create a PolygonCollider2D object, and add contour points to it to create a bounding polygon. Put that polygon in the "Bounding Shape 2D" field of the collider. The camera will then be confined to that polygon
     
  38. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    Yes, I'm using FreeLooks but this patch didn't fixed it.
     
  39. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
    Any chance you could send me your project so I can track it down?
     
  40. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    Right now my project is almost 5GB because of the lighting, I will archive it into .rar file (without lighting) and send it to you tomorrow (pm). :)
     
  41. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
    @JacobSmaga Thank you, I appreciate that very much. You can email it to me at (my username here) at Unity3d.com.
     
    JakubSmaga likes this.
  42. fabioColombini

    fabioColombini

    Joined:
    Dec 9, 2013
    Posts:
    30
    Thanks,
    It worked with Confine 3D and Confine 2D with polygon!
     
  43. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
  44. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    464
    So at this moment i have a problem. I have a few cameras for bobbing states which dont have any body or aim properties and differs only by noise settings. I need to blend them additively with my POV camera because if i add to them POV aim module they will have different rotations. As inheritance is not possible I could've fix this problem by using cinemachine mixing camera, but as i can see mixing camera only allows overriding weights and not adding. Also i have a strong feeling that noise module needs to be removed as an individual vcam module and added in body and aim modules separatly.
     
  45. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    464
    Ability to link mixing camera to blendtree in animator and use this in state drive camera would be very usefull.
     
  46. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
    @Onigiri You are making some interesting suggestions here, and I would like to understand better what you are trying to do. Can you explain the purpose of these bobbing vcams, and the final effect you are trying to achieve?
     
  47. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    464
    I will try to explain my problem better, sorry for bad english. I was trying to add bobbing movement to my POV camera by using stateDrivenCamera. I created 2 POV cameras with different noise setting, but failed with this setup, because both cameras have unique rotations and i cant blend only noise settings.

    After that i try another setup with mixing camera, but with this setup i cant do it so both of my cameras have full intensity.

    Thats why i am offered the ability to have "additive" mode for mixing camera.
    I think i can make it working in 1 case by just copying rotation from one camera to another with custom extension.
     
  48. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,623
    @Onigiri Thank you for that detailed explanation. It's very helpful. What I understand is this: you have a POV camera whose position you are manipulating outside of Cinemachine. You would like it to bob up and down, with a frequency and intensity that is correlated to the character's state.

    First thing: I don't understand why your first state-driven-camera solution didn't work. Both POV cameras are reading the same input, so should have should have the same value, and so the cameras should have the same rotations. The SDC blend should be perfect. Why does this not work? Let's try to debug that before moving to more complex solutions.

    Can you go back to your first try, without the mixing camera, and enable the "Enable all child cameras" feature in the SDC? What happens when you do that?
     
  49. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    464
    @Gregoryl Oh, i didn't see that checkbox. All is working nicely now, thank you very much!
     
    Gregoryl likes this.
  50. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    Project sent.
     
    Adam_Myhill and Gregoryl like this.