I would like to reduce as much as possible the cost of collision detection on my iPhone game. I am planning to use only box colliders for the collisions of the character controller with the environment.
Nevertheless, my hero character also needs to perform some raycasting against the actual rendered mesh of the environment or against other box colliders which are not used for the collisions of the character controller itself.
So basically, different components of the same hero character need to perform collisions requests against different collision layers.
How should I setup the Layer Collision Matrix in that case?
Are you attempting to add extra colliders to change the shape of the character controller? The controller can only use the default capsule shape and any extra colliders you add will be ignored. Beyond that, the entries in the matrix simply denote whether a object from one layer will register a collision from an object in another layer. For example, you could set up the matrix so that the controller will only collide with objects from a single layer and then use a layer mask to control which layers can be picked up by the raycasts.