• 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
Question by GTASUPERFAN · Aug 06, 2014 at 10:15 PM · c#errorgamehorrorslender

Ambient Script CS0163

Hi, i am making a slender game but i got this error,

Assets/Slender 1/AmbientScript.cs(43,25): error CS0163: Control cannot fall through from one case label to another

here is the script

 using UnityEngine;
 
 public class AmbientScript : MonoBehaviour
 {
     public int timer = 100;
     public Transform rotateme;
     public AudioClip fs1;
     public AudioClip fs2;
     public AudioClip fs3;
     public AudioClip fs4;
     public AudioClip fs5;
     public AudioClip fs6;
     public AudioClip fs7;
     public AudioClip fs8;
     public AudioClip fs9;
     public AudioClip fs10;
     public AudioClip fs11;
     public PlayerScript view;
     public AudioSource wind;
     public IntroScript intro;
     public LoseScript loser;
     
     private void Start()
     {
         this.rotateme.Rotate(new Vector3(0.0f, Random.value * 360f, 0.0f));
     }
     
     private void Update()
     {
         if (this.intro.gamestarted && this.loser.timeleft == 0 && (!this.view.mh || this.intro.timer >= 1600 && this.view.mh) || this.loser.timeleft > 250 && this.loser.timeleft < 900 && this.view.pages >= 8)
         {
             this.wind.volume = 1f;
             --this.timer;
             if (this.timer > 0)
                 return;
             this.timer = (int) ((double) Random.value * 500.0) + 100;
             switch (this.intro.timer >= 1700 ? (int) ((double) Random.value * 9.0) + 1 : (int) ((double) Random.value * 8.0) + 1)
             {
             case 1:
             case 2:
                 if (!this.view.lost && !this.view.daytime || this.view.lost && this.view.daytime)
                 {
                     AudioSource.PlayClipAtPoint(this.fs1, this.transform.position, 1f);
                     break;
                 }
                 else
                 {
                     AudioSource.PlayClipAtPoint(this.fs8, this.transform.position, 1f);
                     break;
                 }
             case 3:
             case 4:
                 if (!this.view.lost && !this.view.daytime || this.view.lost && this.view.daytime)
                 {
                     AudioSource.PlayClipAtPoint(this.fs2, this.transform.position, 1f);
                     break;
                 }
                 else
                 {
                     AudioSource.PlayClipAtPoint(this.fs9, this.transform.position, 1f);
                     break;
                 }
             case 5:
             case 6:
                 if (!this.view.lost && !this.view.daytime || this.view.lost && this.view.daytime)
                 {
                     AudioSource.PlayClipAtPoint(this.fs3, this.transform.position, 1f);
                     break;
                 }
                 else
                 {
                     AudioSource.PlayClipAtPoint(this.fs10, this.transform.position, 1f);
                     break;
                 }
             case 7:
             case 8:
                 if (!this.view.lost && !this.view.daytime || this.view.lost && this.view.daytime)
                 {
                     AudioSource.PlayClipAtPoint(this.fs4, this.transform.position, 1f);
                     break;
                 }
                 else
                 {
                     AudioSource.PlayClipAtPoint(this.fs11, this.transform.position, 1f);
                     break;
                 }
             case 9:
                 switch ((int) ((double) Random.value * 3.0) + 1)
                 {
                 case 1:
                     AudioSource.PlayClipAtPoint(this.fs5, this.transform.position, 1f);
                     break;
                 case 2:
                     AudioSource.PlayClipAtPoint(this.fs6, this.transform.position, 1f);
                     break;
                 case 3:
                     AudioSource.PlayClipAtPoint(this.fs7, this.transform.position, 1f);
                     break;
                 }
             }
             this.rotateme.Rotate(new Vector3(0.0f, Random.value * 360f, 0.0f));
         }
         else
             this.wind.volume = 0.0f;
     }
 }


Can someone help me please?

Comment

People who like this

0 Show 0
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

Answer by tanoshimi · Aug 06, 2014 at 10:18 PM

You need a break; at the end of case 9. Also, move your breaks out of if/else parts of cases 2,4,6 and 8, like this:

 case 1:
 case 2:
   if (!this.view.lost && !this.view.daytime || this.view.lost && this.view.daytime)
   { AudioSource.PlayClipAtPoint(this.fs1, this.transform.position, 1f); }
   else
   { AudioSource.PlayClipAtPoint(this.fs8, this.transform.position, 1f); }
   break;
 case 3:
Comment

People who like this

0 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 GTASUPERFAN · Aug 07, 2014 at 07:08 AM 0
Share

thanks, but i cant get it to work maybe you could put it into the script for me?

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

error CS1519: Unexpected symbol `void' in class, struct, or interface member declaration? 1 Answer

cause the object appears in front of the player when colliding with another object 0 Answers

Error trying to createMonoBehaviour using the 'new' keyword in cSharp script 4 Answers

Progress lost after resetting game 2 Answers

Multiplayer Script error 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