Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

What to do about the max. 65K colliders in a scene?

Discussion in 'Scripting' started by toreau, May 21, 2014.

  1. toreau

    toreau

    Joined:
    Feb 8, 2014
    Posts:
    204
    According to the Unity3D documentation:

    "Note that the PhysX engine used by Unity only handles a maximum of 65536 colliders in a scene."

    My problem is that I have a multiplayer (networked) game, and one scene will easily contain more colliders than that, because I let the players build objects themselves, and the scene already has a lot of collider-enabled objects like trees and such.

    How should this problem be handled? Should I just surrender to the PhysX limitation and go from there, or are there ways to "cheat"?

    One thing I've thought of myself, is to have trees etc. with no colliders, but have them - individually - enable their collider when another collider-enabled object is close enough.

    But that won't scale; there's a chance that all the players will be close enough to another object to trigger that effect, with the unknown-ish consequences that will lead to.

    Then there's the migraine-triggering idea of having several scenes, with adjacent terrains, but I don't even know where to start with that in regards to sync'ing the states of several scenes - and their players and other objects - over the network. :?

    Suggestions, anyone?

    Thanks!
     
    Last edited: May 21, 2014
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,738
    If your scene has more than 65k colliders, you should rethink the way it works - PhysX limitation or not - because it would be slow as balls.

    Having "collision zones" is the clear correct solution to your problem. Once every 5-10 seconds, loop through all your zones, check for a player in the zone, and switch them based on that. Better yet, spread that loop across many frames so the game doesn't stutter. There shouldn't be any especially weird, unanticipated issues with that.

    Having a large world with many networked players should have "zones" anyway to be able to unload resources as you don't need them. I think the 65k collider limit will be the least of your problems in this scenario - unless your art is all based off a single texture, you're going to run out of video memory LONG before you run out of colliders.
     
  3. toreau

    toreau

    Joined:
    Feb 8, 2014
    Posts:
    204
    Thanks for the reply, and it makes perfect sense.

    Bonus question! :) Would you have a each player enable the colliders on objects nearby, or should the objects themselves enable their colliders if there are other collider-enabled objects nearby?

    I would think the former, but you never know. :)
     
  4. toreau

    toreau

    Joined:
    Feb 8, 2014
    Posts:
    204
    Anyone has an idea?
     
  5. AndyJenkins30

    AndyJenkins30

    Unity Technologies

    Joined:
    Oct 31, 2016
    Posts:
    190
    Hello!

    I believe the 65k limit for the number of rigid-bodies will be removed with the new version of PhysX 3.4 which is on the horizon:
    https://devtalk.nvidia.com/default/...-physics-modeling/max-number-of-rigidbodies-/

    With that said, as StarManta correctly pointed out above, you should give some serious thought into whether this is actually what you wish to do! Zones is a nice idea.

    Are you using static colliders for your trees? What is the purpose of your large number of colliders? (I am guessing to restrict player movement based on what you've said)

    Networking makes this a much more complex problem, if you have non-static colliders that have to be synchronized over the network. To answer your question if that isn't the case:

    "Would you have a each player enable the colliders on objects nearby, or should the objects themselves enable their colliders if there are other collider-enabled objects nearby?"

    I would have each client enable/disable colliders of nearby objects based on distance from the player. That way no matter how bad the latency, locally you wouldn't run into issues and it'll help reduce your network traffic!

    Hope that helps, let me know if you have any more questions.
     
  6. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,377
    Did someone from Unity just necro a post?

    Well, I guess we can't make fun of the newbs for it no more.
     
  7. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,381
    @AndyJenkins30 you just necro'd this post so hard we're going to have to change your username to LeeroyJenkins30.
     
  8. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    Well... at least it's good to know this limit is going away. :rolleyes:
     
  9. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Andy only has 6 posts, so still ok to pick on the newbs :p

    Also glad to hear this limitation will be going away, not that I needed it to. One less limitation to worry about is all the better.
     
    lordofduct likes this.
  10. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,377