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 Larsthedude · Nov 05, 2016 at 03:11 PM · animationscripting problemaudiomenuloadlevel

Help with script for Main Menu?

So... I'm making a game! But what's a game without a main menu!?

What I'm trying to do with this code is the following...

  • Play music tracks on start [WORKS]

  • Animate a "Fade-from-Black" to the menu [WORKS]

  • Have the player press "any key" to start the game [NOT WORKING]

  • Animate a piece of text on the GUI upon "any key" being pressed [NOT WORKING]

  • Play a sound effect upon the game starting after "any key" being pressed. [NOT WORKING]

  • Play a Fade-to-Black animation... [NOT WORKING]

  • Load Next Scene [NOT WORKING]

My Problem (I believe,) is that my boolean isn't activating upon the keypress, which would trigger the boolean to start the game, which would trigger... everything else!

Could you guys check out my script and tell me where I went wrong? Thank you... I'm not getting any error messages and I've given up on trying to work this out on my own :(

  var StartUpNoise : AudioSource; 

  var Fadein : Animation; 

 var MenuMusic : AudioSource; 

 var GameStart : boolean = (false); 

 var AnyKey : boolean = (false); 

 var Gunnoise : AudioSource; 

 var FadeOut : Animation; 

  var PointMove : Animation; 

  var Point : GameObject; 

function awake() { FadeIn.PlayOneShot(); StartUpNoise.Play(); yield WaitForSeconds(5); MenuMusic.Play(); }

  function update () {
      if(Input.anyKey){
          AnyKey = !AnyKey;
 }

 if(AnyKey){
     GameStart = !GameStart;
 }

 if(GameStart){
     Gunnoise.Play();
     FadeOut.PlayOneShot();
     Point.SetActive(true);
     PointMove.PlayOneShot();
     SceneManagement.SceneManager.LoadScene("Level001");
 }
 else {
     AnyKey = false;
     Point.SetActive(false);
 }        

}

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Larsthedude · Nov 05, 2016 at 04:28 PM

Solved it! It was a variety of issues. Just some event coding. All good.

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

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

Related Questions

Question on Audio? 1 Answer

Trouble with syncing 2D animationClip and AudioClip on Opening Animation 0 Answers

How to hear audio in an animation while previewing,How to hear audio while previewing animations 0 Answers

Sending raycast to animate a object 1 Answer

hy iam using this cript to l;oad next level and drive data from scriptable object and its work fine in editor /play mode but not working in build game /androide or pc 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