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 /
avatar image
0
Question by grimaceaddict · Jun 01, 2016 at 05:15 PM · inputif statementskip

Help with skipping intro

I'm creating a game with an intro, but I want to have the option to skip the intro by pressing a button. I did some searching and found the best format for this would be if (Input.GetKeyDown("keyname") { whatever you want to happen }

But this isn't working. Specifically what I think is happening is that the "if" statement is being run right away, before I even press the button. What this means is that I'll try to load the intro and it will just go straight into the game. I don't know why this is. Could someone give me a suggestion?

Here's the code:

 void Start () {
 if (Input.GetKeyDown("enter"));
         {
             load ();
         }
     } 
 void load(){
         SceneManager.LoadScene ("scene1");
     }

Note: This is only my latest attempt at a fix, I've tried several other things like putting the LoadScene right in the "if" statement without making a whole other function. I also tried creating a variable that went from 0 to 1 when enter is pressed, and the scene is meant to load when this variable is 1. Both of these gave me the same result. Just thought I'd save some time to anyone who would have suggested those things.

Thanks in advance.

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 gjf · Jun 01, 2016 at 03:06 PM 0
Share

Start(), as the name suggests, runs at the start. if you want to check at regular intervals, put the code in Update()

avatar image grimaceaddict gjf · Jun 02, 2016 at 01:57 PM 0
Share

That doesn't seem to fix the problem, unfortunately.

Wait, never $$anonymous$$d! I just tried it again and it works now! Thanks so much!

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Flaring-Afro · Jun 01, 2016 at 05:23 PM

Put the if statement in the Update method instead of Start.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers

How to use Input.GetAxis in if statement 1 Answer

Animation doesn't play on Input 1 Answer

Gui list and color 0 Answers

Why moveDirection.z doesn't work? 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