Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
6
Question by ina · Dec 26, 2010 at 10:13 AM · physicsrigidbodyruntimedisableenable

Enable or Disable Rigid Body at Runtime?

Is it possible to enable/disable the rigid body component at runtime?

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

9 Replies

· Add your reply
  • Sort: 
avatar image
20
Best Answer

Answer by insominx · Mar 06, 2013 at 07:57 PM

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 · Show 7 · 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 Linus · Jul 08, 2013 at 08:08 PM 0
Share

Unity 4.1.5f does not give any warning when using rigidbody.active = false I further checked the change log and I can not find where it says it is deprecated. But there is no mention of rigidbody.active in the script docs

avatar image mateiasu · Aug 13, 2013 at 01:05 PM 0
Share

That's true. Neither does the hint since 4.2 say that this is the way to go. Ins$$anonymous$$d it drops a silly message : 'obsolete, use enabled for enabling / disabling components' <- DOES NOT WOR$$anonymous$$ :D

avatar image Jesdisciple · Apr 21, 2014 at 06:27 PM 0
Share
  • This is far more similar to enabled = false than removing the component (or setting it to kinematic). Thanks!

avatar image Christopher Simon · Jul 10, 2014 at 10:13 PM 1
Share

Isn't it supposed to read: rigidbody.**detect**Collisions = false;

avatar image CleverToucan · Feb 28, 2017 at 05:20 PM 0
Share

This is deprecated in Unity 5+, use rigidbody.is$$anonymous$$inematic = false ins$$anonymous$$d

avatar image kalibcrone CleverToucan · Jul 13, 2017 at 01:37 PM 0
Share

I am using 5.5.3f1 and it is not deprecated.

Show more comments
avatar image
18

Answer by dcocchia · Apr 14, 2012 at 10:35 PM

You probably just want to do .rigidbody.isKinematic = true.

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 123iamking · Feb 03, 2016 at 03:32 AM 0
Share

Yes, that's the trick!

avatar image jeagudelo76 · Jan 20, 2021 at 09:03 PM 0
Share

Finally !!! Thank you so much <3333333333

avatar image
6

Answer by Eric5h5 · Dec 26, 2010 at 08:21 PM

You can't enable or disable rigidbody, but you can destroy it with Destroy and add it back with AddComponent.

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 RElam · Feb 20, 2013 at 05:29 AM 1
Share

Unfortunately, you can't if you have something depending on it, like a CharacterJoint, so you're screwed on ragdolls. Doing rigidbody.is$$anonymous$$inematic = true will give the desired behavior, but at a significant performance penalty, even with paired collider disabled.

avatar image Tryptex · Oct 08, 2017 at 05:05 PM 0
Share

@ Eric5h5 thanks sooo much, I did not know you could destroy and add a rigidbody to a gameobject, now I only have one problem, is there a way to change settings for the rigidbody when you add it the gameobject? I need to freeze the rotation on the z axis.

avatar image
2

Answer by jchart7 · Mar 08, 2015 at 04:11 PM

Ref: http://docs.unity3d.com/ScriptReference/Rigidbody-isKinematic.html

 using UnityEngine;
 using System.Collections;
 
 public class ExampleClass : MonoBehaviour {
     public Rigidbody rb;
     void Start() {
         rb = GetComponent<Rigidbody>();
     }
     void EnableRagdoll() {
         rb.isKinematic = false;
         rb.detectCollisions = true;
     }
     void DisableRagdoll() {
         rb.isKinematic = true;
         rb.detectCollisions = false;
     }
 }enter code here



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 bawi · Aug 26, 2011 at 08:29 AM

can we add "Add Component" on the selected game object we want? how?

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 srmojuze · Jul 29, 2014 at 06:51 AM 1
Share

thegameobject.AddComponent("Rigidbody");

avatar image ahmedkhemiri466 · Aug 03, 2021 at 11:46 AM 0
Share

target_gameobject.AddComponent( Rigidbody );

  • 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

21 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Disable Rigidbody Function Start 1 Answer

Enable/Disable a Static object 1 Answer

Rigidbody velocity limiter 0 Answers

Connect two rigidbody gameobjects together at runtime? 0 Answers

Disabling isKinematic on a hinge joint at runtime - keeping motion to axis 0 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