I have a building with multiple floors and I want to make it so that if my avatar (it’s from an isometric view, think old school games like Crusader: No Remorse or X-Com: UFO Defense) moves up a level, the floor below and above it vanishes, showing only the level the avatar is on.
For example, my avatar enters a multiple floored building at the first level. How do I make it in Unity so that the building’s upper floors fade away as soon as my avatar enters, leaving only the floor the avatar is on to be visible?
If somebody could point me in the right direction or tutorials, it would be much appreciated.
If you still need things like physics to be active, as long as each floor is it’s own mesh you could just disable the MeshRenderer component for floors you don’t want to see.
But i need this to fade the floors, when touching different colliders.
Problem with the Solutions i found - they all need Materials to be “Transparent/Bumped Diffuse”. But when changing all materials to the needed shader, i can look through floors, edges or overlapping objects… That´s not good…
What i need is this, with smooth fading of the floor Object:
Its being culled, partly or fully depending on what the designer wants. You can do this several ways, the easiest I can think of is to split the building into the levels you want shown, and use seperate layers in unity - then cull out what you don’t want to be seen, when you don’t want it seen.
Using layers is not the best option in my opinion. If you have more than one building on the screen, the floors of all those buildings will be culled.
I would directly implement what Dustin proposed. That would be something like: Create a Collider for each floor and make it a tigger to find out in which floor the character is. Depending on that, deactivate/activate the mesh renderers of the floors, such that only the one you want become visible.
I use EZGUI for my 2D interface, but it has a number of animation/transition functions that work with any GameObject, one of which will animate the color/alpha of any material. I’d bet there are probably other animation plugins available that will let you change alpha over time to fade objects in and out. Or you could just write your own alpha fade function, although if you want non-linear easing that gets a bit more tricky. Just gradually reduce the material’s alpha to zero, then deactivate the renderer.