- Home /
Peculiar geometry behaviour question (antichamber)
Hello,
It's really hard trying to put my thoughts into words with this question. So here's a description of what I wish to achieve. If there is anyone who can push me in the right direction then I can't thank you enough. ok, here we go:
Imagine an empty room with a door in the middle, there are no walls surrounding that door, it's just there all alone. But when you open the door you don't see the back of the room you're standing in. no, you see the wall of an entire new room. (This might be the hardest thing for me to explain)
So: You are in room A, you open a door in the middle of the room (with no walls around it) and when you go through it you are in room B (which is impossible in reality)
Does anyone have any idea how I can do that with unity? I don't need codes worked out for me or anything, a push in the right direction is all I'm asking.
The same phenomenon is seen in Antichamber (the game).
**EDIT - BETTER SOLUTION -> http://forum.unity3d.com/threads/191890-Unity-4-2-Stencils-for-portal-rendering**
Answer by Jamora · Aug 01, 2013 at 08:21 PM
This kind of behavior can be achieved using RenderTextures. Unfortunately it's a Pro only feature, so if you're working with Unity Free you'll have to come up with another method.
Basically, you have the door, as you explained it. Immediately behind the door you have a teleport to handle the player from moving to this room. Immediately behind this teleport, you'd have a RenderTexture that just renders what a camera sees. This camera is placed in the other room, to the location of the door. This setup will cause the door image to be static, in the sense that it won't change if the player looks at it from a different angle.
If you want a better 3D effect for the RenderTexture, you will have to move the camera in the other room based on the movement of the player, so it seems the space behind the door is, in fact, 3D.
I'm now using the RenderTextures method, but I can't figure out how to "move the camera in the other room based on the movement of the player" correctly. Could you maybe explain how I do that?
A simple way I was thinking was just matching the rotation of the camera to that of the player's. It would probly have to be clamped to a 180 (a bit less, depending on your field of view) degree area so it wouldn't show what's behind the door.
But to make it more realistic, you'd have to calculate the angle of the player to the render texture, then have the camera rotated by the same amount. I made this picture I hope will clarify what I mean.
But because this can not happen in reality, you can make it look like whatever you want, I'm sure your players can accept a magical portal that doesn't move in relation to the player...
I dunno what happened; it worked in the morning when I last checked it. I uploaded it again. I also found this quite interesting Answer
I'm trying many things, translating the camera, rotating the camera, but nothing works.
and another thing, when I walk towards the door, the perspective gets distorted too. It's really breaking my brains
I thought this was what you meant ->
That looks pretty good, to me at least.
To further explain my picture: the camera can be anywhere; the dotted line is just there to show that the angle should be calculated to a plane that is rotated similarly to the RenderTexture plane.
I'm all out of ideas if this one doesn't work, sorry.