- Home /
Render only one room instead of all.
Here are 2 pictures of my current setup.
http://goo.gl/aSgsI <-- outside
http://goo.gl/NxFpd <-- inside
Currently I have a box collider set to trigger on each building and tagged as "Interior". Then when the player enters an "Interior" trigger I swap the layers that the camera renders. All the Interiors are on one layer and the outside world on another.
Now I want to be able to render only the interior that I am in. rather than all. Using layers is not particularly feasible as there is a limit to those.
I wish to avoid teleporting the player to a different location.
Any suggestions? Thankyou
I did try to search this but was finding to think of keywords to search for.
Answer by Bunnybomb7670 · Jun 07, 2013 at 12:21 PM
A way I think you could do it is by storing all the gameobjects for each interior in an array , then have it so the box collider stores which house it is attached to and it disables the renderers on all the other gameobjects in the array. This will work, it just takes time to setup.
Main script with all interiors:
GameObject[] interior = new GameObject[10];
void Start()
{
for(int i =0; i < interior.Length;i++){
interior[i].renderer.enabled=false;
}
}
and another script attached to the collider :
GameObject attached; // Interior mesh.
void OnTriggerEnter() {
attached.renderer.enabled=true;
}
void OnTriggerExit(){
attached.renderer.enabled=false;
}
The idea of this is to disable all renderers for interiors on startup and then enable them when the player enters the house and disable again when they leave it.
Your answer
![](https://koobas.hobune.stream/wayback/20220613103709im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Downward pointing face on cube discoloured 0 Answers
Obfuscating DLL classes from the users 1 Answer
Lightmaps/objects and textures 2 Answers
Fog Of War For Unopened Rooms 1 Answer
Hiding and showing multiple objects 1 Answer