I have 2 cameras in my 2D game.

One displays gameobjects normally, and the other camera draws some of these gameobjects reflected (scale.y *= -1). The reflected camera would draw only objects in the "Water" layer, and I would change the layer of the GameObjects I want to reflect on the precull and postrender functions. This way I can decide which GameObjects would be reflected, changing the layer on the fly at runtime, which is a requirement.

-Precull: Change the desired GameObjects layer to "water", and apply scale.y*= -1

-OnPostRender:  Change the Gameobjects layer to their original value, and apply scale*= -1

This was working correctly when my objects were simple, but now my objects are more complex, and I can't rely on changing the layer of the gameobjectson the fly, as I can't tell what their original layer was for each part of the object, in order to revert the changes applied during the precull.

Is there anyway to tell a camera which objects should it render besides using the culling mask?


You could use shaders instead.

Here is a link of one that may help http://wiki.unity3d.com/index.php/SurfaceReflection.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.