Open a door and enter the same room

Hello there,
what I want to do: build a room with two doors. When the player open one door and enters it, the player would show up at another door in this room.
My qestion is how I can achieve this function. Or where I have to look after support.
Looking forward to your answers.

Forums like this one are ideal for posting when you are stuck mid doing something. Meaning - after you did some work and not sure how to continue further or maybe being stuck for some technical reason.

Too vague or broad questions are generally not received well and not because of lack of good will but because this shows no proof of invested time/work (basic knowledge, scripts, screenshots etc) on their part. It also suggests that this person didn’t even bothered to google for tutorials on this matter of which there are more than plenty around the web.

Help everyone know this is not describing you by showing some stuff done already here, anything, and make sure it’s abundantly clear to your readers that you googled for tutorials.


I kinda of agree with andrew, there are a ton of tutorials showing how this can be done, Unity Learn site has several tutorials which will help you to understand what you should do to make this happen. But here is some pseudo code or steps you could take.

Create a Door MonoBehaviour component and assign it to your door visual game object. Also add a collider to your door and set it to be a trigger.

In the Door MonoBehaviour, create a field for target transform. Its position will be used as target where player will end up. Assign another door’s transform as target or some other suitable object, if door’s position is not suitable, like a location in front of another door.

In the same script add an OnTriggerEnter or OnTriggerEnter2D method, depending on which physics system you use. In the OnTriggerEnter method, check if collider entering is player’s and if so, set player’s transform position to be that of target transform position.

You can then use the same component in the other door, only this time using suitable target object for that door.