Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
This question was closed Jan 26, 2016 at 11:18 AM by Daniel_Zabojca for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Daniel_Zabojca · Jan 05, 2016 at 01:26 PM · characterinteractionlevelsgameplay

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

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ShadyProductions · Jan 05, 2016 at 01:39 PM 0
Share

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?

avatar image Daniel_Zabojca ShadyProductions · Jan 06, 2016 at 07:48 AM 0
Share

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

2 Replies

  • Sort: 
avatar image
1
Best Answer

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;
 }
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Daniel_Zabojca · Jan 06, 2016 at 08:07 AM 0
Share

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.

avatar image ShadyProductions Daniel_Zabojca · Jan 06, 2016 at 10:02 AM 0
Share

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.

avatar image
0

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Daniel_Zabojca · Jan 07, 2016 at 08:09 AM 0
Share

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

Answers Answers and Comments

38 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges