Streaming content in and out using UnityFor anyone using Unity curious about something simple like streaming content in and out here's one way it can be done.
Streaming can mean different things in games but in this case I'm just activating and deactivating objects on the fly.
Here's a gif showing it in action, from top down | player perspectives (using some gameplay abilities just to get around quicker)
The player has a collider tagged
"Vision" spanning roughly the same area as seen by the player camera.
Attached to this
"Vision" collider is a rigid body with continuous collision detection as well as a script telling it to activate & deactivate the child of any object with a collider tagged
"World Manager Env" upon entering and exiting respectively.
Why the child and not the main object? because if you deactivate the main object then it's gone and can't be detected again. Parenting all environment assets to a parent object means that the parent is always active and ready to act when touched.
Here are some of the
"World Manager Env" collider objects (no rigid body needed) holding large environment pieces as children. (Didn't select all pieces or the screen shot would look like a mess.) Just make sure that the colliders almost fully engulf all environment geometry or else you'll see rocks and trees pop into existence as you run.
I also had a script run on all
"World Manager Env" collider objects individually saying on start to check if they are touching the players
"vision" collider, if so then stay activated. If not then after .1 secs deactivate. This allows me to always have all environments visible while working but the necessary ones deactivate or activate as soon as I run the game.
Not sure how confusing that was. If you're confused it is probably my fault for not writing it well.
Thanks,