[Unity 5.5] Tutorial: How to create a Mirror

Hello guys!
Today we are going to create a Mirror in unity 5!

(This tutorial is mainly ment for beginners, so that’s why I exaclty explain every detail what I do :wink: )

I hope you guys like it!

Also if you got any questions, just ask in the comments!

Thanks for this awesome tutorial. one question, do you know how we can reflect the light on mirror, light should point to opposite direction after interacting with mirror ! thanks again :slight_smile:

Looks terrific, thank you! :smile:

How is it that this thread didn’t get more comments ? Also, I just went on the you tube page for this video and three people downrated it??? :frowning:

I’ve made this tutorial with Unity 2018.2 and it works rather well. I just have a slight problem. Here is your script:

using UnityEngine;

public class Mirror : MonoBehaviour
{
    public Transform mirrorCam;
    public Transform playerCam;

    private void Update()
    {
        CalculateRotation();
    }

    public void CalculateRotation ()
    {
        Vector3 dir = (playerCam.position - transform.position).normalized;
        Quaternion rot = Quaternion.LookRotation(dir);

        rot.eulerAngles = transform.eulerAngles - rot.eulerAngles;

        mirrorCam.localRotation = rot;
    }
}

If I use it as it is, the mirrorCam rotates on the x axis instead of staying at 0:

Things get better if I change

rot.eulerAngles = transform.eulerAngles - rot.eulerAngles;

in CalculateRotation(), into

rot.eulerAngles = (transform.eulerAngles - rot.eulerAngles).normalized;

but there is still a slight rotation (1 degree sharp) on the x axis:

Hello,
First, I’d like to thank you for the tutorial! It was fantastic! However, I ran into an issue with the angling of the camera and after several hours of toying around with it and trying to make the mirror work properly, I needed to take a break. The picture below is the view that I get from the mirror upon approaching it. I am very new to Unity, so I’m sure it’s a simple fix, I just don’t know exactly what the issue is. The camera is facing into the room, not into the sink, and yet the mirror’s reflection simply wont face the right way. Even the rotation is fine, it seems to follow me as I walk around, but it just wont reflect at the right angle. Some help would be very much appreciated.

EDIT: Changing the angle of the camera and scale of the mirror texture doesn’t seem to fix the problem either. In fact, it just ends up reflecting the room that is on the other side of the wall.

4446955--407464--Mirror dilemma.png