Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by Johan 4 · Mar 02, 2011 at 08:39 PM · rigidbodyenabled

Disabling a rigidbody.

How do I disable a rigidbody? If I do rigidbody.active, it tells me to use enabled instead. But rigidbody doesn't have enabled property.

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

5 Replies

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

Answer by Jessy · Mar 02, 2011 at 08:44 PM

What does "disable" mean, to you? Changing to kinematic with a trigger collider is the closest you can come, other than disabling the entire Game Object or destroying the component.

Comment
Add comment · Show 1 · 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 darbotron · Sep 22, 2015 at 09:51 PM 0
Share

Jessy is right, I tried lots of approaches and the only one that seems to work is essentially what he suggested, to "turn off" physics for a Rigidbody just do:

 // This code definitely works in Unity 5.2
 // you should check ( rb != null ) before using rb...
 Rigidbody rb             = gameObject.GetComponent< Rigidbody >();
 rb.detectCollisions     = false;
 rb.is$$anonymous$$inematic        = true;    

this will stop the physics system calculating physics interactions for the object & it will remain still unless you move it. Just do the opposite to turn it back "on".

If you want to do the same thing for a trigger, you can just disable the collider using Collider.enabled = false & re-enable by setting it to true.

Note that any behaviour you have in your code that relies on detecting the enter & exit of a collision or a trigger might well break when using these techniques - when you set Rigidbody.detectCollisions or Collider.enabled to false that will NOT call the OnCollisionExit / OnTriggerExit.

avatar image
0

Answer by Squarefish · Dec 14, 2012 at 03:10 PM

I have a similar problem with rigidbodies. My game engine as far as collisions are concerned are using the Collision() methods, which always require convex rigidbodies (as far as I can tell)

My problem is whilst handling all velocities, positioning myself that the rigidbodies interfere with eachother as they are conscript of Unity3d's physics engine. This occurs rarely as I'm using settings which minimise reactions from the physics engine, however...

It's bad enough having to use rigidbodies to use the Collisions class functions but is there a way to totally disable physics?

(The previous answer here is a little inadequate as it recommends disabling the GameObject or destroying a needed component)

Comment
Add comment · Show 1 · 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 Fattie · Dec 14, 2012 at 03:13 PM 0
Share

huh? if you don't want to use a game engine, and don't want to use PhysX, then don't use a game engine. just program using Corona or something else, or just move images around raw as an XCode project.

you talk about calculating your own velocities, positions etc. that's just kind of weird. you just use PhysX to do all that.

if you don't want to use rigidbodies - don't use them. if you don't want to use colliders - don't use them.

avatar image
0

Answer by Squarefish · Dec 14, 2012 at 03:40 PM

I like Unity3d.. personally I feel a bit beaten back by your comment, and so would others.

I wanted to calculate all my own velocities and positions because of the nature of my project.

I have no idea what you mean by using XCode.

I've seen similar posts to mine about collisions not being accessible without rigidbodies. This is my main complaint of Unity3d and I've coded a workaround if there is no solution for turning physics off. I do want to use Colliders. Not Rigidbodies.

By god, there are many reasons to use Unity3d... not only for PhysX!

Your post is totally deconstructive from a programming point of view.

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 Fattie · Dec 14, 2012 at 05:14 PM 0
Share

it could be your comment is misunderstandable, no offense.

In any event you now say "I wanted to calculate all my own velocities and positions because of the nature of my project."

If so - no problem at all. Don't use PhysX, rigidbodys or colliders.

If I understand you, you want to use colliders YES but NOT use rigidbody to move the item, but you want to move it yourself - but - even though you're moving it yourself you want the colliders to work ?!?

Is that about correct? If so, the answer is simply "oh you can't do that"

Just move them yourself (as you say) and make your own colliders.

Further, let's go back to this statement

"I wanted to calculate all my own velocities and positions because of the nature of my project."

just FTR, it's sort of a mathematical law that - there is no need to move them yourself. TBC, there is nothing you can't do (by moving them yourself) that you can't achieve by having PhysX move them.

(TBC I've many times "moved things myself" in rigs, and indeed you can always just use PhysX to move them, ins$$anonymous$$d, for the same result. But the point is no, it's not possible to "move around" colliders yourself, and expect PhysX to work - you can't do that. You'd have to write your own colliders.)

there are many strange rigs you can build using Unity,

for example

http://answers.unity3d.com/questions/299407/character-collision-of-walls-inside-moving-ship.html

but in any event you can't use colliders unless you're letting physX move it.

FYI

"I wanted to calculate all my own velocities and positions"... once you set the velocity of something, the position is deter$$anonymous$$ed (unless you don't believe in eg Peano's aioms)

although it's "not normal" to do so, you can freely set the veolocity of stuff in physX (ie, of rigidbodys) as you wish. this is a "normal" if you will advanced technique (to make comets fly around stars or whatever)

avatar image Fattie · Dec 14, 2012 at 05:14 PM 0
Share

PS pls post comments as comments, not new answers

avatar image
0

Answer by Squarefish · Dec 14, 2012 at 05:21 PM

I'd like to apoligise and let you know the point I raised earlier, was fallible.

Although you can't "turn off physics" for using Collider function classes and you do need a Rigidbody:

You can turn effects of physics off by clicking in the Rigidbody dialog freeze positions X,Y,Z and likewise for freeze rotations.

You can edit the positions and rotations by coding them in the usual way, whilst using this feature.

Comment
Add comment · Show 1 · 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 Fattie · Dec 14, 2012 at 05:23 PM 0
Share

there's no need to apolgise, for goodness sake!

BTW if possible please just click the S$$anonymous$$ALL CO$$anonymous$$$$anonymous$$ENT BUTTON to comment rather than using a new "answer"

you can do what you say but people will think you're a pervert :)

Just FTR you can always achieve the same by just setting the velocity of the rigidbody (every FixedUpdate, if you particularly want to). But ENJOY !

avatar image
0

Answer by davidnibi · Feb 08, 2020 at 10:29 AM

 yourRigidbody.constraints = RigidbodyConstraints.FreezeAll;


or

 yourRigidbody.constraints = RigidbodyConstraints.FreezePosition;
 yourRigidbody.constraints = RigidbodyConstraints.FreezeRotation;
 





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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

script wont re activate object when my conditions are met 1 Answer

JS - How do I change the constraints of an object? 1 Answer

Making a ship move 1 Answer

Hinge joints disconnect when pulled too far. 0 Answers

Rigidbody - freeze rotation and position? 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