Is it possible to assign game objects to a layer through code at startup?

I am wandering it it is possible to assign objects to layers that have already been created with code.

My ultimate goal is to have some objects visible for each player in a multiplayer environment. More specifically I have battleships fighting in split screen. And I have long narrow planes that are children of the turrets that make it easier for the user to see exactly where the turrets are facing. And I want the plane that belongs to each user only to be visible in each user's camera and not the other.

I want to make plane1 belong to the player1 layer, which will be visible in player1's camera. and the same for player2. I will screen out the unwanted planes in the other cameras.

Thank in advance.

Easiest way is probably NameToLayer:

object1.layer = LayerMask.NameToLayer("My Layer");

Does anyone know how this can be done to include the children of parent?