Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by z_master · Aug 12, 2015 at 04:22 AM · rigidbodyperformancedisableragdolliskinematic

How to disable Rigidbody component completely

I am working on a game that have some characters that become ragdolls and after some time, they come back to be controled by animations, the only way I found to do this is setting isKinematic to true in the rigidbodies, which improved the performance compared to leaving isKinematic on false, but even with the isKinematic set to true the performance wasn't even close to when I removed completely the rigidbodies.

What can I do to make the rigidbody be completely ignored by the engine while the character is being controled by the animations?

Should I create the Rigidbodies and the Joints components when I want to activate the ragdoll then remove them when they come back to animations?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

6 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by DarthHawk13 · Jul 08, 2016 at 10:10 AM

Here's an example and it works for me. I can turn the rigidbody of an object on and off as I need to.

         private Rigidbody rBody; //or public Rigidbody rBody; 
             
             void Start()
             {
             rBody = GetComponent<Rigidbody> ();
             }
             void Update() //or in any function
             {
             if (something)
             {
                     rBody.detectCollisions = false;// this will not affect the graphics
 // of an object but will make other rigidbodies pass through itt without 
 //triggering a collision
             }
         
         }

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
2

Answer by simulism · Sep 15, 2016 at 11:17 AM

I know this is old but you could use:

 GameObject.AddComponent<Rigidbody>();

to add a Rigidbody when you need it and then use:

 Destroy (rigidbody);

to remove the Rigidbody when not needed.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by samra2494 · Mar 07, 2019 at 07:10 AM

In Unity 4.0+ Rigidbody.active is deprecated and may no longer be available but you can do this:

  rigidbody.detectionCollisions = false;
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Fredycom · Aug 12, 2015 at 12:49 PM

Right click on the "Rigidbody component" and I think it might say "Remove Component" or something like that click it.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by GiyomuGames · Aug 12, 2015 at 05:37 AM

Have you tried

 GetComponent<RigidBody>().enable = false

?

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image z_master · Aug 12, 2015 at 12:13 PM 0
Share

When I tried this line , I received the error:

error CS1061: Type UnityEngine.Rigidbody' does not contain a definition for enabled' and no extension method enabled' of type UnityEngine.Rigidbody' could be found (are you missing a using directive or an assembly reference?)

avatar image GiyomuGames · Aug 12, 2015 at 12:25 PM 0
Share

Ah yeah it doesn't work indeed, sorry I didn't have Unity near me and this works on all components implementing $$anonymous$$onoBehavior (so I guess RigidBody doesn't).

$$anonymous$$aybe you can try calling the RigidBody Sleep method. Not sure what will be the effect to be honest.

  GetComponent<RigidBody>().Sleep()

http://docs.unity3d.com/ScriptReference/Rigidbody.Sleep.html

  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Eject Overlapping Bodies Without velocity 2 Answers

rigidbody simulation collision check frequency check control?? 0 Answers

Rigidbody not responding after toggling isKinematic 2 Answers

How can I move a rigidbody ragdoll without velocity? 0 Answers

CharacterController or Collider/Rigidbody 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges