Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  5. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  6. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Disabling Physics2D in Cinemachine

Discussion in 'Cinemachine' started by Stormy102, Jun 7, 2018.

  1. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    454
    Hi,
    In 2018.2b, disabling the Physics2D component (which isn't needed in a 3D game like ours) results in an error as Cinemachine depends on components from this module. Will this problem be rectified in a future release by disabling the relevant components or will I still need to keep this module enabled?

    -Matt
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,408
    Yes there are a small number of classes in Cinemachine that have dependencies on 2D physics, simply in order to support 2D games. In the current release, it might be only CinemachineConfiner. You could just delete it.
     
    Stormy102 likes this.
  3. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    454
    Are there any plans in which you can detect which modules are installed? It's just that we use source control along with an automated build server, so just deleting it wouldn't be an option upon the full 2018.2 release...
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,408
    Yes, but you're going to have to find an interim solution until then. Maybe just don't disable the 2D physics module for now.
     
    Stormy102 likes this.
  5. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    454
    No worries. We're just experimenting with 2018.2b at the moment, before we do a full-scale upgrade. Thanks for the response. :)
     
  6. Feelnside

    Feelnside

    Joined:
    Sep 30, 2016
    Posts:
    31
    Could you please clarify how to delete this script? I'm trying to do it but it's a part of the Cinemachine package, so I don't have access to it.
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,408
    You would have to embed Cinemachine in your project. This is done by copying the files from the Package Cache into your Assets folder, then removing CM from the project's manifest. Then you can edit the scripts. You can ask for more details about embedding packages on the Package Manager forum.
     
  8. Feelnside

    Feelnside

    Joined:
    Sep 30, 2016
    Posts:
    31
    Understand, thank you!
     
  9. Hubertsn

    Hubertsn

    Joined:
    Aug 7, 2015
    Posts:
    6
    Hello @Gregoryl,

    I have been running into this problem as well using Cinemachine 2.2.7 without Physics2D package. I suggested Package Dependent Compilation in the Package Manager Forum.

    Meanwhile I have been trying to use my own symbols for packages and modified the Cinemachine package making Physics2D optional. 4 scripts depend on Physics2D: CinemachineConfiner.cs, CinemachineConfinerEditor.cs, CinemachineCollisionImpulseSource.cs, CinemachineTriggerAction.cs.

    Maybe I found a bug while doing that in CinemachineColliisonImpulseSource.cs.
    Code (CSharp):
    1.         private float GetMassAndVelocity(Collider other, Collider2D other2d, ref Vector3 vel)
    2.         {
    3.             bool getVelocity = vel == Vector3.zero;
    4.             float mass = 1;
    5.             if (m_ScaleImpactWithMass || m_ScaleImpactWithSpeed || m_UseImpactDirection)
    6.             {
    7.                 //...
    8.                 var rb = other != null ? other.attachedRigidbody : null;
    9.                 if (rb != null)
    10.                 {
    11.                     if (m_ScaleImpactWithMass)
    12.                         mass *= rb.mass;
    13.                     if (getVelocity)
    14.                         vel += rb.velocity;
    15.                 }
    16.                 //Shouldn't rb2d refer to other2d?
    17.                 var rb2d = other != null ? other.attachedRigidbody : null;
    18.                 if (rb2d != null)
    19.                 {
    20.                     if (m_ScaleImpactWithMass)
    21.                         mass *= rb2d.mass;
    22.                     if (getVelocity)
    23.                     {
    24.                         Vector3 v = rb2d.velocity;
    25.                         vel += v;
    26.                     }
    27.                 }
    28.             }
    29.             return mass;
    30.         }
     
    Stormy102 likes this.
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,408
    Awesome! You're way ahead of me!
    Adding conditional symbols is on my todo list!
    And thanks for the bug report - you're absolutely right.
    Cheers!
     
    Hubertsn likes this.
  11. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    454
    Nice to see even Unity suffer from copy-paste code bugs :D