Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by D4NG3RCL0S3 · Jan 26, 2013 at 04:23 PM · javascriptguidoor

Door to Next Level HELP!

Hi! For about 2 days I have been trying without success to create a door that brings you to a different scene like from a Fallout game or Elder Scrolls game. I've been trying to make it so that when you are within a distance and your cursor is pointing towards the door, then it will say 'Click F to Enter "Scene"' And then when you click F it brings you to a Different scene. Like in my game you spawn in your home and you want to go outside, I was manageable to make it so if you click a key like 'F' then it takes you "Outside" but I could do that anywhere like from halfway across the room not even looking at the door... If you can help me it would help alot!

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer Wiki

Answer by Flickayy · Jan 26, 2013 at 05:41 PM

Take a look at Application.LoadLevel for loading different scenes.

 // Load the level named "HighScore".
 Application.LoadLevel ("HighScore");

You could then use Triggers and the method OnTriggerEnter to check if the character is near the door, then load the level when "F" is pressed. Something a long the lines of this. I know it's not exactly the method you wanted, but I hope you can at least use some of this.

 using UnityEngine;
 using System.Collections;
 
 public class example : MonoBehaviour {
     void OnTriggerEnter(Collider other) {
         if(other.gameObject.name == "DoorTrigger"){
           if(Input.GetKey("F")) {
             Application.LoadLevel("NextScene");
           }
         }
     }
 }


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 D4NG3RCL0S3 · Jan 26, 2013 at 10:34 PM 0
Share

Thanks! that helped a lot actually!

avatar image Flickayy · Jan 27, 2013 at 03:17 PM 0
Share

Always happy to help!

avatar image
0

Answer by Kortekk · Jan 26, 2013 at 05:37 PM

Look into use raycasting in order to detect whether the player is facing an interactive object:

http://docs.unity3d.com/Documentation/ScriptReference/Physics.Raycast.html

You can adjust the distance parameter to change the minimum interaction distance.

Comment
Add comment · 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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 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

Related Questions

Setting Scroll View Width GUILayout 1 Answer

WorldToScreenPoint returns the same value when facing the opposite direction. 0 Answers

Player wont be found on start 1 Answer

Creating a next and previous Tutorial 1 Answer

Lowering a variable 1 number lowering it entirely? 1 Answer


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