• 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
Question by King-Klong · May 02, 2018 at 03:40 PM · physicsrigidbodycollidervrcolliders

When and when not to use kinematic rigidbody?

I have a VR game with a scene with a few enemies that the player can aggro, and then kill them with a few sword swings. There are no physics interactions (things bouncing off one another), just colliders passing through each other. Currently, everything only has colliders on them, no kinematic rigidbodies. The docs say that if a collider moves around with no rigidbody (a static collider), it has a performance cost, and there can be inaccuracies with raycasts and such.

Apparently the performance cost of moving a static collider was drastically reduced in a 5.x build at some point. This seems true because I made a scene of 1000 moving cube with and without kinematic rigidbodies. When I ran the game without kinematic rigidbodies, I got ~70fps. When I ran the game with kinematic rigidbodies on the cubes, I only got ~13fps, with most of the processing going to the physics (I also used the rigidbody.position to move the cube).
So by those numbers, I feel like if I'm not using a rigidbody to behave with physics, I should just not use it because it adds more processing. But, does not having a kinematic rigidbody on a collider cause inaccuracies still? Is it fine for my sword and enemies to only have colliders and no kinematic rigidbody? Or what is most efficient/accurate way?
It is getting hard to trust what the docs say...

Comment

People who like this

0 Show 3
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 TanselAltinel · May 02, 2018 at 08:22 PM 0
Share

Why do you set the rigidbodies to kinematic? Do you know what kinematic means?

avatar image King-Klong · May 03, 2018 at 12:32 AM 0
Share

Yes I do know what isKinematic does. I do not want physics to control the positions of the objects, so if I were to use a rigidbody, I would set isKinematic to true. I would just not use rigidbodies at all, but what I keep seeing on the internet is that moving a collider with no rigidbody is a no no. I've read through the docs on these multiple times ;).

avatar image TanselAltinel King-Klong · May 03, 2018 at 07:36 AM 1
Share

Well, that is a no no. I just don't understand if you are not going to use physics why use colliders.

Did you take a look at the Unity example project how characters are build? https://unity3d.com/learn/tutorials/s/survival-shooter-tutorial

2 Replies

· Add your reply
  • Sort: 
avatar image

Answer by Harinezumi · May 03, 2018 at 08:15 AM

Based on your description I think you need is trigger colliders with kinematic rigidbodies. Rigidbodies because they move, trigger because things don't bounce off each other, and kinematic, because they are moved by logic.

Why do I say this? Well, this is how I basically think about physics in Unity. A game object...
- ...without collider: does not take part and/or care about physics; purely logic or visual
- ...with trigger collider: a static (non-moving) detector area, for triggering logic when something enters it
- ...with (non-trigger) collider, without rigidbody: static physical object, real, solid things that won't move, like walls, the ground, etc.
- ...with (non-trigger) collider and non-kinematic rigidbody: dynamic physical object, a thing that moves according to the laws of physics, like boxes, balls, projectiles, etc.
- ...with (non-trigger) collider and kinematic rigidbody: dynamic physical object, but it doesn't behave purely with physics, usually because it is moved by player input or animation or some other logic

These cover most cases and makes it pretty clear what to use in what situation. Note that you can switch kinematic on and off depending on the situation. For example, normally your player character can move with user input with kinematic rigidbody, but when it gets blown up by and explosion you make it non-kinematic and let physics handle how it flies and falls.
Btw, as far as I know these are all the collider types in 3D: SphereCollider, BoxCollider, CapsuleCollider, MeshCollider, AND CharacterController.

Comment
Bunny83
Veftaxop
daniel_diazsanchez
FattywithHacks
jtrupiano

People who like this

5 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 King-Klong · May 03, 2018 at 02:53 PM 0
Share

This is what I was thinking too, to use trigger colliders with kinematic rigidbodies. However, in my test scene with 1000 moving cubes with trigger colliders, when having kinematic rigidbodies on the cubes, there was much more physics processing going on, resulting in about 13fps. And without rigidbodies, I got around 70fps. So with those results, it makes me think that if hit detection is still accurate, I shouldn't use rigidbodies then since they are more processing intensive to move. Any thoughts on that?

avatar image Harinezumi King-Klong · May 03, 2018 at 03:19 PM 0
Share

That is surprising, because moving static colliders is supposed to be costlier than ones with rigidbodies! I'm pretty sure that using trigger colliders with kinematic rigidbodies should work fine, but maybe this is a bug, or other quirk of the physics system.
So I researched a bit, but I could not find any information or reported issue about the topic. The only thing I can think of is that maybe rigidbody.MovePosition() should be used (maybe rigidbody.position (which instantly moves) is costlier? This is just a guess). You could also try to use rigidbody.velocity, but it feels like a hack...

Sorry, this is all that comes to my mind. If you do find a solution, please post it, so that others may find as well. Btw, what version of Unity are you using?

avatar image

Answer by Harley-B · Jul 12, 2018 at 07:11 AM

You did the right thing. You tested it - don't worry about what the conventional wisdom is, worry about results. I've run similar tests with similar results and I move my colliders around without rigidbodys too.

Comment

People who like this

0 Show 0 · 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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

192 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 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 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 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 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 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 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

How to make two colliders or rigidbodies stick together upon collision, as if there was a glue on their surfaces? 3 Answers

Forklift pallet physics 3 Answers

Ignore sub-colliders for center of mass in Rigidbody2d? 1 Answer

Tossing an object with the correct force at any distance from another so that it collides with the other 1 Answer

Grabbing a handle in VR and rotating it like a crank? 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