The question is answered, right answer was accepted
How to make it so that when you open a door you enter the room you want to exit?
Hello everyone,
I have another question, and I will get straight to the point.
How can I make it so that if the player does not interact with an object (lets make it a key) and he wants to exit the room through interacting with the door, he enters the same room again. (Something PT made made you enter the same hall over again, I kind of want to reproduce that.)
How can I make the door part possible? I am working in 3D mode if that is important to know.
Thank you all in advance, Daniel Nowak Janssen
Why don't you just return a message saying he needs to get the key? But if you really want to do it that way, I guess you could set the player's transform to the position of the doors room?
But I also have an interaction with the door. Its like this : I walk to the door, and I press interact with the door. The open door animation plays and let me get go to another room, or I enter the same room. That is what I try to achieve. I watched a few tutorials explaining how to achieve that, and I tried to reproduce the effect This is my current script :
       using UnityEngine;
       using System.Collections;
       public class Teleporter : $$anonymous$$onoBehaviour
        {
    public Transform exit;
 static Transform last;
 /// <summary>
 /// This one above makes it so that I can not spam warp spawn From point A to point A. 
 ///
 /// </summary>
 void OnTriggerEnter(Collider other)
 {
     ///<summary>
     ///If you collide with it then you exit at point B, WIth an secure No spam warping protection.
     /// </summary>
     if (exit == last)
         return;
     TeleportToExit(other);
 }
 void OnTriggerExit()
 {
     if (exit == last)
         last = null;
 }
 void TeleportToExit(Collider other)
 {
     last = transform;
     other.transform.position = exit.transform.position;
 }
 
   }
I made it possible to teleport on collision. Now Should I change the onTriggerEnter Collision other to getkeycode.Something and make a ray cast which gets the distance to the point? Like this : I Walk to a door, I am 2f from the door and the trigger has activated for me to be able to interact with the door. I press (example button) E and A ray gets cast out from the middle of my screen and when it collides with the door which has a door script it starts an animation. And the screen freezes during the animation and unfreezes after the animation. During the animation it should teleport me to another door and play the animation if I did not do something right.
How can I perform that? I mean the teleportacja, freezing of camera AND the animation play at the same time.
Thank you in advance, $$anonymous$$ Nowak Janssen
Answer by tanoshimi · Jan 05, 2016 at 01:50 PM
Something like...
 void OnPlayerInteractsWithDoor(){
   if(playerHasKey)
     teleportLocation = locationOfNewRoom;
   else
     teleportLocation = locationOfCurrentRoom;
 
   player.transform.position = teleportLocation;
 }
Thanks for the quick reply!
Does that include the animation? Because It only would teleport the player to another location, and I do not know if it would also include playing the open door animation (It's a simple code that slerps the door 90 degrees, nothing special).
Thank you in advance, $$anonymous$$ Nowak Janssen.
If the animation is in mecanim you can set up a bool there, and when the animation finishes the bool is automaticly set to false when the animation exits, that way you can see when to tp the player.
Answer by Curb · Jan 05, 2016 at 01:50 PM
I always imagined they had several copies of the room connected to the door in P.T. and in code it would decide which room to load/enable (either the same one or a slightly different one) to make the transition seamless.
I got a tip from someone, and I wanted some confirmation if it also works like that.
He said that you have to go to a location in front of the door, and then it plays an animation and teleport you to the beginning room (from bathroom to entrance to the house).
Can it be done like that? Or does it use a lot of data?
Follow this Question
Related Questions
Moving player from platform to platform 0 Answers
Need help to move my character between different levels 0 Answers
Changing player co-ordinates 0 Answers
posing character in gameplay 0 Answers
VR Problem : interacting with a NPC with Vive Controllers 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                