- Home /
 
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?
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
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
 
             Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Parent Object Via Code C# 3 Answers
Adding a bar that reset for each level 4 Answers
How To Add PlayerPrefs Scores? 1 Answer
resetting object on collision 1 Answer