- Home /
create a portal with texture render
hi can any one please explain or give some tutorial on how to make a non walk trough portal in unity pro. some thing like this all i have managed to fine is that it's easy, but never the answer. i have build a plane and put on it the camera texture but how do i keep all the perspectives so it look like a portal.
thank's.
Answer by robhuhn · Jan 14, 2013 at 02:14 PM
I don't know the code but I would say it works as follows.
attach one camera to portal0 and another to portal1 both looking away from the portal (-1 on local z). They are used to render the texture.
calculate difference between portal0 and portal1 -> diff
apply the negative transformation of the main camera to the portal cameras, add the linked portal transformation and add the diff from above.
May be like that the more or less. Hope it helps to get the idea.
also, i found another question about portals on unity answers which is exactly what you need: http://answers.unity3d.com/questions/123547/seamless-portals-into-other-spaces.html
thank you for tiring to help me. but can you please b a little bit more specific? i have tried this as much i understood but i have nothing :(
i have created 2 main objects portal0 and portal1 that each contain a camera and a "screen" that shows the camera (texture render) the code is?
void Update () {
GameObject $$anonymous$$ainCamera = GameObject.Find("mainCamera");
GameObject portal0Camera = GameObject.Find("portal0Camera");
GameObject portal1Camera = GameObject.Find("portal1Camera");
GameObject portal0 = GameObject.Find("portal0");
GameObject portal1 = GameObject.Find("portal1");
Vector3 diff = portal0.transform.position - portal1.transform.position;
portal0Camera.transform.localPosition = $$anonymous$$ainCamera.transform.localPosition * -1 + diff;
portal1Camera.transform.localPosition = $$anonymous$$ainCamera.transform.localPosition * -1 + diff;
}
thank u.
I'm really interessted in this and also like to know how to achieve that effect. I will create an example project tomorrow and post some details if I get it to work. I think it's not the diff between the portals but between e.g. Portal0 and main camera which then is applied to the cam of the other portal. I'll know more tomorrow.
hi, i found another question about portals on unity answers which is exactly what you need: http://answers.unity3d.com/questions/123547/seamless-portals-into-other-spaces.html
Answer by MattewMarkson · Jan 14, 2013 at 11:41 AM
this is looking as mirror, just create a render texture, and camera. assign this render texture in camera render texture, and then apply this rendertexture to your object. Done!
i did it. but how do i keep all the perspective. i want it to look something like this
you see that if the main camera is traveling then the texture render is changing accordingly
how can i do thaT?
Answer by DanJC · Apr 25, 2013 at 08:36 AM
http://answers.unity3d.com/questions/421450/how-can-i-render-a-scene-to-a-surface.html#answer-444650
A two-line shader, and it works in Unity Standard. Handles the view but not the actual relocation.
Your answer
![](https://koobas.hobune.stream/wayback/20220613090919im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
making a non walk through portal 2 Answers
A way to code teleporters for different teams? 1 Answer
How to make the Skybox visible only through a window? 3 Answers
Portal issue and transform.position 0 Answers