- Home /
How do i make a mirror?
I am making a replica of my house inside unity and as the title sugguests, I need to find out how to make a mirror. I dont have unity pro, I dont want to have to buy an asset and I barely know the basics of scripting. The best i can think of is placing a camera in the mirror and having a texture display what the camera sees on the mirror, but i dont even know how to do that! Anyone care to help me?
Answer by fffMalzbier · Jul 31, 2014 at 11:50 AM
Without unity pro -> Rendertextures (The thing that is getting the image from a camera and put it into a texture) , you will no be able to have a mirror like you described easily.
There is some trickery that can be done like this
https://www.assetstore.unity3d.com/en/#!/content/8530
there may bee free packages too out there in the net if you have luck finding them.
I just came across this links, not tried them check if they help:
Answer by Cinder · Mar 24, 2015 at 03:49 PM
With Unity 5.0 personal/pro probes are now viable but still a bit meh in some conceptual ways. to get it to work as a mirror I used this script: var plane : GameObject; var character : GameObject;
var offset : float;
var directionFaced : Direction;
function Update () {
if(directionFaced == Direction.X){
offset = (plane.transform.position.x - character.transform.position.x);
transform.position.x = plane.transform.position.x + offset;
transform.position.y = character.transform.position.y;
transform.position.z = character.transform.position.z;
}
if(directionFaced == Direction.Y){
offset = (plane.transform.position.y - character.transform.position.y);
transform.position.x = character.transform.position.x;
transform.position.y = plane.transform.position.y + offset;
transform.position.z = character.transform.position.z;
}
if(directionFaced == Direction.Z){
offset = (plane.transform.position.z - character.transform.position.z);
transform.position.x = character.transform.position.x;
transform.position.y = character.transform.position.y;
transform.position.z = plane.transform.position.z + offset;
}
}
//makes the possible directions
public enum Direction{
X,Y,Z
}
With the variable "plane" being the mirror surface and the "character" being the player's camera. There's a few other things I had to do to make this actually work and I go into step by step detail in the video here.