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
0
Question by barbe63 · Jan 19, 2015 at 04:55 AM · rigidbodyactivekinematic

Active kinematic rigidbodies

Hello,

I'm trying to solve something with my NPCS that can get in a ragdoll state to fall with physics and stand up after a while.

So initially they are kinematics and moved by navmesh agent and when they go in ragdoll state they aren't kinematic anymore. The problem is all parts are detected as active rigidbodies even in normal state, even if I remove the colliders from those parts. How could I force them to sleep? Is it supposed to happen?

Thanks to enlight me!

Comment
Add comment · Show 16
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 barbe63 · Jan 19, 2015 at 07:53 PM 0
Share

Please guys i really need an answer for that.. I suppose this probably sounds like a silly question for some of you, so that means you could answer ;)

avatar image PvTGreg · Jan 20, 2015 at 09:19 AM 0
Share

The problem is all parts are detected as active rigidbodies even in normal state, what do you mean by this

avatar image barbe63 · Jan 20, 2015 at 09:48 AM 0
Share

I mean they are not sleeping even if my NPC is not in ragdoll state(understand non influenced by physics, that means all colliders for all bones are deactivated and the rigidbodies attached to it are kinematics). I tried this morning to change the structure of my NPC to make the rigidbodies, colliders, joints and all attached stuff childrens of the bones (so I can deactivate them when wanted). They are no longer active in the physic engine but the ragdoll state is totally broken so I guess that was a bad idea too...

EDIT: Actually to make this more simpler, the problem occurs with every rigidbody attached to my NPC. They are set to kinematic but they are still active(not sleeping). I even put a key to set all active rigidbodies to sleep but that doesn't work meaning they wakes up instantly.

I read somewhere that a kinematic rigidbody should not use physics cycles. Here they say why a rigidbody would awake.

"another rigidbody collides with the sleeping rigidbody" $$anonymous$$y physic matrix should prevent that. The only collision i see is with the ground which is of course not a rigidbody.

"another rigidbody connected through a joint is moving." Sure they move but they are kinematics too and therefore should sleep also.

"when modifying a property of the rigidbody" I only set the is$$anonymous$$inematic to true or false when needed. Unless the changing position done by the parent is consider changing a property? In that case what should I do?

" when adding forces" I don't.

avatar image fddefdef · Jan 20, 2015 at 10:17 AM 0
Share

Do you mean that when the NPC is controlled by the navmesh you want it to be kinematic and so not affected by physics? Cause putting a rigidbody kinematic won't deactivate the collider component but only renders it useless cause you won't detect collisions anymore. So if your problem is that you have to manually deactivate the colliders when you want to.

avatar image barbe63 · Jan 20, 2015 at 10:24 AM 0
Share

"Do you mean that when the NPC is controlled by the navmesh you want it to be kinematic and so not affected by physics?"

yes, if the navmesh agent is active the NPC should not be affected by physics and my collisions are detected via a trigger.

"Cause putting a rigidbody kinematic won't deactivate the collider component but only renders it useless cause you won't detect collisions anymore. So if your problem is that you have to manually deactivate the colliders when you want to."

When exiting from ragdoll mode I deactivate bones colliders(not triggers) in the same time i put them kinematics, I also reactivate the normal collider of the parent (which is trigger) and events are received that way. When going to ragdoll mode it's exactly the opposite procedure.

Show more comments

2 Replies

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

Answer by barbe63 · Jan 20, 2015 at 07:47 PM

Wow i didn't lost my day!!

My solution to destroy rigidbody and to rebuild them makes my game run much faster on my mobile. The physic engine have 1ms of work when it was 10!! That progress is 10 times more than i expected and the same amount more of what i gained since I started to optimize my game (since about 2 weeks). I even think i will put my realtime shadows back and some timestep less!

@tanoshimi I wasn't sure i would gain performance by setting those rigidbodies to inactive since as you said i also thought that as long as they were kinematic the engine would barely take them in account. But now i know I was wrong! (and that i was right to search this way ^^)

Thank you guys, my solution is not yet the same results i had but almost and i really gained a lot!

EDIT:Indeed! Now my game can run really nice with some realtime shadows and 1.5 time step instead of 2. I like this day :p

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 ricardo_arango · Jan 20, 2015 at 05:59 PM

You can force an object to Sleep for one frame using Rigidbody.Sleep. If the object is in contact with other objects, in a hierarchy of rigidbodies (not recommended), connected via joints, has forces are applied to it via scripting, it receives gravity, etc (what's described in the page you linked http://docs.unity3d.com/432/Documentation/Components/RigidbodySleeping.html), it will be awaken or kept Awake. For a rigidbody to sleep it needs to be resting with no forces being applied to it.

Note that is not recommended to have multiple Rigidbodies in a hierarchy of objects, but instead a single "root" rigidbody.

You can affect how quickly a Rigidbody comes to rest with the sleepVelocity and sleepAngularVelocity components.

Why do you need to Rigidbody to be inactive?

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 barbe63 · Jan 20, 2015 at 07:12 PM 0
Share

I did the Sleep() fonction in a script that detect all non sleeping rigidbodies. That doesn't work since they probably wakes up instantly.

I have to make all those individuals rigidbodies in the same hierarchy so i can use the bone system. What are joints for then?

i need them to be inactive so the physic engine have 10 times less work to do with active rigidbodies.

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

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

Related Questions

Kinematic how to know rigidbody velocity vector? 1 Answer

DragRigidbody script, setting / unsetting to kinematic 1 Answer

Kinematic vs. RigidBody for Basic motion. 0 Answers

Tracking Force Added to Kinematic Rigidbody 2 Answers

Set velocity of kinematic rigidbody appropriately 1 Answer


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