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 CerebralStatic · Jul 02, 2021 at 07:55 AM · collisioncollider3d3d models

Collisions, but on 100,000 cubes?

I'm making a city in Blender for a flight-sim type game. The player space is spacious, spanning many kilometers. The city is full of buildings, potentially a quarter million or more. Now due to the scale, each building is basically a cube with a little extra geometry here and there. To grossly oversimplify, I want to import the entire city and all its subcomponents into Unity where I will organize the objects in the scene, yada yada.

But simple set-dressing isn't my goal, for the player can fly through the buildings and collide with them. Falling rigidbodies can bounce off surfaces, etc.

So, my question is this: what would be the best and most performance friendly way to give each building collisions? Should I slap a performance hungry mesh-collider on components of the whole city object, or should I include literally 100,000 individual collider objects identical to the city geometry and apply a box collider script to each one?

Surely there's a solution that saves time and performance... right? Surely I haven't dug my own grave... ha ha... right?

Comment
Add comment · Show 1
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 CerebralStatic · Jul 02, 2021 at 07:58 AM 0
Share

By the way, the buildings are not prefabs. The city is literally 1 single object with the 100's of individual buildings procedurally generated, edited, unwrapped, separated and sorted into large areas.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Llama_w_2Ls · Jul 02, 2021 at 08:16 AM

There are multiple ways of optimizing your scene with respect to colliders and rendering as well.


One option is to add mesh colliders and set them to Is Convex. This will reduce the level of detail of your mesh collider, whilst keeping a sub-accurate representation of your model's collider. On square-like buildings, mesh colliders set to IsConvex still function exactly the same, but reduce the verts on your collider by a lot.


Another option is to use occlusion culling. You can do this manually or using Unity's automatic system. To do this manually, when a building is out of the player's view (so like 100m away), disable the building object entirely (or just the collider/renderer). This way, less objects need to be simulated at once. To do this automatically, set the object to static (occlusion static), and make sure occlusion culling is enabled on your camera. It will automatically disable renderers of objects out the camera view for you.


For rendering, you can merge all the building's meshes into one mesh (or sub meshes per material, if they have different materials), then add a mesh collider on the combined object/s. This reduces draw calls and optimizes physics calculations, as there are less objects for the GPU to worry about drawing at once.


Another tip is to set the building game objects to static. Lightmap static optimizes lighting calculations (since the buildings don't move so realtime lighting isn't needed), and batching static allows similar materials to be batched together (which reduces draw calls). If you need dynamic batching (objects can't be static), in the material properties, in advanced, enable GPU instancing. This produces the same performance increase as batching the objects together.


Finally, LOD's. You can set up an automatic level-of-detail system for your buildings using the Unity LOD camera component. By setting buildings further away to a lower level of detail, you can optimize the collider and mesh geometry by a whole lot. There are a few tutorials of using LOD systems, and simplifying geometry.


Hope these tips are useful. I know there are a whole lot more that I'm not aware of, but good luck :) @CerebralStatic

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 CerebralStatic · Jul 03, 2021 at 05:36 PM 0
Share

Thank you! I'll give these a try! I don't know if I'll be able to use Occlusion Culling depending on how the map is built, but I hope so, that would really help.

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

239 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 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 might Colliders be treated differently on retina iPads? 2 Answers

How can i check if a trigger is completely full? 1 Answer

How do I change the collision in showcase the book of the dead? 0 Answers

Destroy Terrain Trees And They Collider 0 Answers

Some questions about Concave Collider 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