Using a collider to define the boundary of a level?

I am working on an underwater game where the user pilots a submarine around an underwater world. I would like to create an invisible spherical wall around the important part of my level, so that the user can’t leave the area (though they can see terrain extending beyond it) I thought I could do this by just putting a giant spherical collider on a null game object centered in the level. Unfortunately, the spherical collider seams to assume that other colliders should always remain outside of it, and will force rigid bodies with colliders outside of the sphere. Is there a way to create a spherical collider that will instead contain colliders, and prevent them from leaving?

Thanks,

-Matt

I think your options may be limited here…here’s something to try, though:

  1. Model your level boundary (correct size) in a modeling program (eg. blender)
  2. ensure your normals are flipped
  3. import to unity and use a mesh collider

The caveat being that I’m not entirely sure how unity generates mesh colliders on import (I’m assuming from surface normals).

Hi mat, you can set the spherical collider to trigger. Then you can ad a

OnTriggerExit function to the player so that something happens when they try to leave. If want them to run into a wall you will have to build a box out of 6 boxes. I dont think you can invert a collider.

Here is another solution that we released today on the asset store.

It allows quick create of complex boundaries for a level.