- Home /
Projector blob shadow ignoring layers configured by script?
I am trying to make a default Blob-shadow appear on the ground elements, but not on the bushes etc.
The game is build up from a sort of tilesetup. As every object is imported in FBX format and we have rather many, I would like to use scripts to put the objects into certain layers.
I have a layer 11 I've named "NoShadow". This layer I want to put my bush into.
// spawn the new object
go = (GameObject)GameObject.Instantiate( (GameObject)ModelController.raw[ ModelController.items_object[ objectList[cnt].index ].index], pos , rot);
go.transform.Translate( pos2 );
go.transform.parent = goParent.transform;
go.layer = 11;
I've tried with other layers too, but no result unless I pick default in the projector. Then every shadow is gone???
Answer by BerggreenDK · Sep 12, 2011 at 08:19 PM
Aaah, I found it myself and I am going to post it for others to learn from it.
When you instantiate objects loaded with Resources.LoadAll and they are imported from eg. Blender in FBX format. They are often encapsulated in a sub-hierachy.
So setting the layer number on the object you've loaded only fixes the top element you've just created. But the actual meshes are in the the child gameobjects.
Therefore you need to loop through the children too and set their layer accordingly.
NOW it works.
Only the object(s) with a ($$anonymous$$esh)Renderer need their layer set.
yes, you mean that the top level object (parent) doesnt need to have its layer set. I agree, but it was just my quick solution to do it recursively.