Instantiate with renderer?

In my game, I have a square room, with walls. The user can rotate around this room to see it from different angles, but obviously the walls get in the way.

I'm trying to make the walls semitransparent when the camera is on one side, but I'm encountering a problem - it seems like when I instantiate the objects to build the wall, they don't have a renderer attached. When I say

wall.renderer.material.color.a = .5;

I get "MissingComponentException: There is no 'Renderer' attached to the "Static Wall(Clone)" game object, but a script is trying to access it." as an error. My wall objects appear textured and shaded, so I assumed they did have a renderer already.

Is there something I'm missing?

1 Answer

1

Solved it myself - the object I was instantiating was actually an empty object parented to a mesh - the child had the renderer, not the object itself.