Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

rigidbody.disable is gone? since when?

Discussion in 'Physics' started by CyberTurboPlays, Jun 28, 2015.

  1. CyberTurboPlays

    CyberTurboPlays

    Joined:
    Nov 7, 2014
    Posts:
    65
    hi

    i want to disable rb and enable them when i need it to.

    sleep or col detection off wont help since the cost remain the same for my game, but removing the rb helps, so i really want to disable rb and enable when needed for my particular situation

    how can i go about this, guys?

    Why would unity remove the enabling/disabling of rb in the 1st place?
     
  2. Osirius

    Osirius

    Joined:
    Oct 10, 2014
    Posts:
    47
    Yeah, Unity removed this a while ago.
    The closest you can get is making it Kinematic and disabling collisions. The processing cost should be much lower for a Kinematic with no collisions.

    Or, you could always add a child object and move any colliders and rigidbodys over, then when you want to disable the rigidbody you could just disable the child object.
     
  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,557
  4. CyberTurboPlays

    CyberTurboPlays

    Joined:
    Nov 7, 2014
    Posts:
    65
    thx man, that is exactly what i did to go around it
     
  5. CyberTurboPlays

    CyberTurboPlays

    Joined:
    Nov 7, 2014
    Posts:
    65
    really wanna know "disable gameobj" and "disable just the RB", which one is cheaper, now i hav no way of knowing that
     
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,557
    I'm guessing that the problem was that when you disabled a Rigidbody component, what should be done with all the attached colliders? Colliders only attach to a Rigidbody that is active on the same GameObject are on a parent GameObject. Disabling the Rigidbody would mean they'd not attach to it and therefore they'd be static which isn't probably what you'd want.

    Disabling a GameObject is more expensive than disabling a single component but it all depends on what components are on the GameObject and its children.

    When I implemented the 2D physics stuff, for this reason, I did not allow the Rigidbody2D to be disabled as the required behaviour wasn't very clear and different users would want different things. This is why I added the option I mentioned above which has a well defined behaviour, only affects the Rigidbody, joints and colliders and is very fast.
     
  7. CyberTurboPlays

    CyberTurboPlays

    Joined:
    Nov 7, 2014
    Posts:
    65

    now i wish we have that on the 3D one la, sounds way cheaper and specific, meaning dont have to guess how much it would cost:)