Hello,
to be honest I’ve already solved this problem time ago, but I can’t remember how I did it (so maybe I’m really getting stupid…).
I’m working on a “mirror” in my scene (yes, the one that you can see in your bathroom), so I’m using a Camera (I’ve named it “Camera_mirror”) with a RenderTexture, placed in the center of the mirror mesh.
Obviously I have to rotate the “Camera_mirror” in Update, so to be always perpendicular to the 1st person Camera (otherwise it would not be a mirror anymore).
Well, maybe I’ve lost a bit of my brain, but I’m getting lost in maths…
To start, I’ve created a simple script to draw the perpendicular from A to B in 2D, and I’ve attached it to the “B” gameObject (that should be my “Camera_mirror”)
P.S. please excuse redundance code, it’s just to clarify
void DrawLine(){
GameObject B = gameObject;
/// Draw line from A to B
Handles.DrawLine(B.transform.position, A.transform.position);
Vector3 dir = A.transform.position - B.transform.position;
Vector3 left = Vector3.Cross(dir, Vector3.up).normalized * 5f;
/// Draw line perpendicular
Handles.DrawLine(B.transform.position, left);
transform.LookAt(left, Vector3.up);
}
Well, it work just if the “B” gameObject is in the center of the world (position 0,0,0)
If “B” is NOT in the center of the world, the perpendicular is wrong
Please can you help me to get back a bit of my brain?
Many thanks!!