Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

If I understand correctly, render textures are a feature of Unity Pro, and that is the best way to create mirrors, TV screens, and so forth. If I am wrong, please tell me. What I would like to know is if there is another, probably less-convenient, way to create a mirror with the free version of Unity. If I need to write a custom script, I would appreciate a basic outline of how to write it. Even better, if you know of a free script package that does this, please tell me.

share|improve this question
    
You might be able to do something that looks like a mirror with cube maps. –  Tetrad Mar 1 '12 at 16:30
add comment

1 Answer 1

up vote 5 down vote accepted

You are correct in that render textures are the best way to do mirrors in Unity. Coincidentally, a game that I worked on recently required the use of mirrors (though our mirrors would also reflect things that may not exist in the world). We were also developing with Unity Free, so we had the same problem as you.

Our solution was as follows (recommended to us by a professional who works with Unity): write a script that copies a GameObject, and strips all Monobehaviour, Physics, etc. components off that object (as well as it's children). Basically all that should be left is the transform and the mesh/material data. Then, depending on the mirror location and orientation, you can change the transform of this shell object to the appropriate location on the other side of the mirror. We used a nifty parenting trick that I can't remember the exact code for. I'll dig into our code when I have a chance and update this post.

For any dynamic objects, you'll have to write a script to update the 'mirror object' based upon the original object's location and animation. You could either store a reference to the original object in your mirror object, or vice versa. This is probably the hardest part of the process.

As for the mirror itself, you can apply any kind of transparent material to it in order to make it look a bit more like the surface you want.

The whole process itself sounds daunting but when it comes down to it, mirroring in this way isn't actually that bad. It's when you want different things happening in the 'mirror world' that it gets messy.

Hope this helps :)

share|improve this answer
1  
That's a great idea, and I think I'll try it it, but what if the mirror isn't against a wall? Wouldn't the player be able to peak around the mirror and see his clone on the other side? –  tyjkenn Mar 3 '12 at 0:17
    
IF the player is able to walk in the space on the other side of the mirror, yes, it becomes a problem. Note that if properly mirrored, the clone of the player will end up on the 'real' side of the mirror when the real player is on the 'mirror' side. Sadly I don't think there's a way to have a mirror in the middle of a room with Unity Free. –  ktodisco Mar 3 '12 at 1:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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