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 /
avatar image
0
Question by TrustEditz · Dec 19, 2015 at 12:23 PM · application.loadlevelinput.getbutton

Changing scene by pressing a key

Hiya! So I'm working on a game completely on my own. I'm not good at all with unity or coding. So my problem is that I want to stand in a cartain area and press a button, which then switches scenes to where you can buy guns (other scene). My code atm looks like this

  void OnTriggerEnter(Collider other)
         {
             if (other.gameObject.tag == "Player")
             {
                 ContinueText.text = Continue;
                 helpText.text = "";
             }
                 if (Input.GetButtonDown("Use"))
                 {
                     Application.LoadLevel("Shop");
                     Debug.Log("Loading level: Shop");
                 }

I added "Use" to the input manager aswell. Anyone knows what I can do to make it work? Atm I don't get any errors.

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
0
Best Answer

Answer by TrustEditz · Dec 02, 2016 at 10:35 AM

If anyone is googling and comes to this topic, the answer was in the function. Instead of using OnTriggerEnter, which only runs when you enter the object. Use OnTriggerStay, which runs as long as you're inside the trigger

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
avatar image
0

Answer by usalalas · Dec 19, 2015 at 12:30 PM

Did you add a breakpoint on line 10 to see if the debugg stops there?

Comment
Add comment · Show 7 · 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 TrustEditz · Dec 19, 2015 at 12:34 PM 0
Share

Don't understand what you mean. Care to show me what you mean?

avatar image usalalas · Dec 19, 2015 at 12:41 PM 0
Share

Well, In $$anonymous$$onodevelop you can add a breakpoint to that line, to see if the script enters there.

avatar image TrustEditz usalalas · Dec 19, 2015 at 12:55 PM 0
Share

I'm using Visual studio

avatar image usalalas · Dec 19, 2015 at 12:44 PM 0
Share

Did you also added the scene in the build settings?

avatar image TrustEditz usalalas · Dec 19, 2015 at 12:54 PM 0
Share

yeah, I have

avatar image usalalas · Dec 19, 2015 at 12:57 PM 0
Share

I'm not used to Visual Studio, but you should be sure that this line is been executed. That's why I asked about the breakpoint.

avatar image TrustEditz usalalas · Dec 19, 2015 at 01:09 PM 0
Share

Yeeeeah, tried it, don't get a notification, even on line of code that runs

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

33 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

Related Questions

Standalone build rotation shuddering with input button 0 Answers

Windows Phone 8.1 crash when loading first scene 0 Answers

Switch Statement Gives Error PLEASE HELP!!! 2 Answers

Calling GetButtonDown on an input axis 1 Answer

I need help getting a sound to play when the E Key is pressed. (E will also load a new Scene). 2 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