- Home /
Is there another way to hide an object
Before I describe my problem let me say that I have a solution but it's not exactly what I am trying to achieve.So,I'm building an isometric game and I need to hide a couple of walls that stop me from seeing my character.I don't know how to do it for only one object at a time ,since they share the same material,in a gradual way.I can hide them by linecasting from the camera to the player every third of a second and disabling the mesh renderer,and it works but it's not very nice looking since the walls just pop out and then in back into existence.So if anyone knows a better way to do it,like hiding gradually,only the object that interfere's with my line of sight,or can point me in the right direction I would very much appreciate it.Thanks
Answer by SmileQ · Jul 17, 2015 at 10:04 AM
How about having 2 materials?
the normal one that you are using for your walls,
a material that is the same as the first one, but would get used when you are trying to fade out.
Then when you want to make a part of the wall disapear, asign the second material to it and fade it out.
Would go like this when you wanted to fade out a wall.
Asign 2. material to this part of the wall
Fade out the 2. material
and when your fading back in, when the alpha reaches max(normal), reasign the first material, so they dont fade out when your fading a new piece of the wall.
that would be a hit for the performance,I'm trying to make this work on mobile and an extra material for each object I need to hide wouldn't be very good,I might as well just add a material per object,but again that's not good for performance.Anyway as I was saying I have a solution it's just not exactly what I want but if no one has any ideas I'll use what I have
Shouldn't be a big hit.
Just use 2 materials in total, not a new one for each object.
Dont create the new material each time you have to fade a part, use the same material.
have a public material that you set in the editor.
Answer by FirePlantGames · Jul 17, 2015 at 04:43 AM
Have you ever considered lowering the walls opacity?
That would affect all objects sharing the same material,so it doesn't work for me