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 par-002 · Apr 20, 2013 at 06:08 PM · collisionphysicsperformancekinematicrigid body

How to deal with *many* moving colliders?

I have a lot of colliders in my game. And they all move. The main object (the player) is a Rigid Body with isKinematic checked. None of the other objects have a Rigid Body, just a collider (atm a Mesh collider but I'm considering punting and using basics).

Everything is a Trigger.

ALL GameObjects that are colliders (excluding the player) are contained in another empty GameObject so I can transform their locations based on a grid system. Meaning, I do not manually move each Collider itself, I just move its empty parent GameObject.

And due to me moving everything, I do not use any physics in my game.

I have read many conflicting sources that say either:

  • Many RigidBody's produce heavy performance load

or

  • Many moving objects with collision should have a RigidBody with isKinematic checked.

I am currently having iOS performance issues and I need to see if I can squeeze as much out of my code as possible.

  1. Can I turn off Physics completely? Or at least enough such that only Trigger collision detection is performed?

  2. Should I keep all collider's as basic colliders or should I put RigidBody's on them with isKinematic enabled?

  3. All colliders fall within 1 of 8 or so basic mesh's (think circle, oval, triangle, hexagon, 4-point star etc) with as few triangles as possible. I currently have "mesh collider" on each of them so that that specific shape is used for collision. Since I have as few triangles as possible, is this ok? Or should I actually just punt and use one of the 3 built-in primitive colliders (Box, Sphere or Capsule)?

Thanks so much!

PAR

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

1 Reply

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

Answer by DESTRUKTORR · Apr 21, 2013 at 07:52 PM

  1. No, you cannot turn off unity's Physics engine, but you -can- utilize it more carefully. OnTriggerEnter, OnCollisionEnter, etc. are only called if they are contained within a behaviour that is attached to a game-object with the proper collider/rigidbody arrangement for that method call, so as long as you only use trigger-colliders (colliders with "isTrigger" checked), you should be good.

  2. isKinematic disables all physics effects on the rigidbody, but allows it to affect other rigidbodies. If you want to know whether an object will get a collision call, simply check the corresponding documentation page. Box Collider, sphere collider, capsule collider, mesh collider, and wheel collider are the only ones available, in unity. If there's no physics involved with a given collider, and it's just a trigger, I'd suggest just not using rigidbodies, and sticking to the trigger collider. Otherwise, depending on how complex the physics will be, you may or may not want to use an attached rigidbody.

  3. Mesh colliders will not collide with other mesh colliders, unless at least one of them is set as convex. However, mesh colliders -will- collide with other colliders that are -not- mesh colliders, with or without being set to convex. However, stick to built in colliders whenever possible. It will likely improve efficiency by quite a bit, as the system knows exactly what the mesh looks like, and is optimized to use it.

Comment
Add comment · Show 3 · 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 par-002 · Apr 22, 2013 at 02:56 PM 0
Share

Thanks for the reply DESTRU$$anonymous$$TORR...

I am still quite confused on how to deal with what I am working with.

$$anonymous$$uch of the documentation says that if you have static collision objects to use just a collider on the object and go from there. The documentation also says if you $$anonymous$$OVE a static collider, you will incur a large overhead due to the physics engine needing to .. do whatever it does (I am seeing this now).

I have also read that putting a rigidbody with "is kinematic" checked will remove the overhead seen from dealing with many objects that are also colliders.

What I am seeing is framerates of 50-55 FPS on an iPhone 4 with all colliders and rigidbodies removed (so my graphics are not an issue). As soon as I have my objects use either a plain collider with isTrigger checked OR a plain collider with isTrigger checked AND a RigidBody w/ is$$anonymous$$inematic checked, I drop to 3-5 FPS.

I have spent the past weekend trying to change my entire engine so that I can keep all colliders but the main object (the player) completely stationary but the way the whole system works I just cannot do it. In order to accomplish what I am trying to do (which I did accomplish with Cocos2d and Box2d on the iPhone) I must have everything moving. That is why I asked if there was a way to remove the Physics completely except for the collision.

I wonder if there is a magic combination of things I must do in order to get this to work the way I want. I'm sure Unity and PhysX can do it... I just dont know what it is.

PAR

avatar image par-002 · Apr 23, 2013 at 09:51 PM 0
Share

So after rewriting the way my entire game moves and trial and error, I realized that what Destruktorr was saying was exactly what I needed to utilize.

I ended up going BAC$$anonymous$$ to my old way of moving the world around via leaving the main player stationary and moving the whole world ins$$anonymous$$d (moving individual layers individually would cause rounding errors after awhile... I have to have movement across all layers exact or my world logic doesnt work).

With that strategy I then created everything as a basic collider (either sphere or box) and then put a rigidbody on all of them with $$anonymous$$INE$$anonymous$$ATIC OFF (this surprised me). This produced by far the best results with one caveat...

I had to put in location logic of the colliders. $$anonymous$$eaning, I have to turn off all colliders that never have a chance to collide with the player until there is a possibility of doing so. W/out this logic, my fps is down in the 5-10 range. With the logic I'm rock s$$anonymous$$dy at 48FPS on an iPhone4.

PAR

avatar image DESTRUKTORR · Apr 28, 2013 at 08:53 PM 0
Share

Glad I could be of assistance :)

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

12 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

Related Questions

Are my kinematic rigidbodies slowing my scene down? 2 Answers

Is Use Full Kinematics Contact bugged in 5.6.1? 0 Answers

Simple Movement Game: Physics vs Manual Collision Detection? 2 Answers

Disable rigidbody from being able to move other rigidbodies 1 Answer

[SOLVED] Desactivate pushing forces between two objects 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