Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 davidflynn2 · Nov 04, 2012 at 11:10 PM · c#leveling

Case structor in C# Unity

I am working on creating a levling system and I cant find anything on how case strucktures work in unity. I have worked in pure c# and created a case structor just not sure whats going on with it in Unity here. Here is my code so far then the error I am geting. If no one know a good solluction would any one plz recomend where I might find some help making a leveling system?

 using UnityEngine;
 using System.Collections;
 
 public class PlayerStatus : MonoBehaviour 
 {
 
     public int curExperience = 1;
     public int curLevel = 1;
     // Use this for initialization
     void Start () {
     
     }
     
     // Update is called once per frame
     void Update () 
     {
     
     switch(curLevel){
         case 0:
         if(curExperience <= 24){
          curLevel += 0;
          }
         case 1:
         if(curExperience >= 25){
          curLevel += 1;
          }
        break;
         case 2:
         if(curExperience >= 55){
          curLevel += 1;
          }
        break;
        case 3:
        if(curExperience >= 95){
          curLevel += 1;
          }    
        break;
        case 4:
         if(curExperience >= 130){
          curLevel += 1;
          }
        break;
        case 5:
         if(curExperience >= 182){
          curLevel += 1;
          }
        break;
        case 6:
         if(curExperience >= 254){
          curLevel += 1;
          }
        break;
        case 7:
         if(curExperience >= 356){
          curLevel += 1;
          }
        break;
        case 8:
         if(curExperience >= 500){
          curLevel += 1;
          }
        break;
        case 9:
         if(curExperience >= 700){
          curLevel += 1;
          }
        break;
        case 10:
         if(curExperience >= 990){
          curLevel += 1;
          }
        break;
     }
     
 
     }
 
 }

This is the error I am geting:

Assets/PlayerStatus.cs(18,9): error CS0163: Control cannot fall through from one case label to another.

If no one know a good solluction would any one plz recomend where I might find some help making a leveling system?

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
4

Answer by Jessespike · Nov 04, 2012 at 11:20 PM

error CS0163: Control cannot fall through from one case label to another.

You're missing a "break;" for case 0 at line 23

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 davidflynn2 · Nov 05, 2012 at 12:27 AM 0
Share

Great job must had looked at it to long lol. Thanks

avatar image Leon Codrington · Sep 15, 2015 at 06:51 PM 0
Share

@Jessespike

I could have spent an evening missing that typo in my script if yours wasn't the first answer I came across..

$$anonymous$$any thanks :)

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

Multiple Cars not working 1 Answer

Can someone help me understand this code. 1 Answer

touch to instantiate and move object ? 1 Answer

How would I use this to check if the player has a key and is touching a door? 1 Answer

Using GUI skin with my GUI Button 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