- Home /
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?
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:
thanks, but i cant get it to work maybe you could put it into the script for me?
Your answer
Follow this Question
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
AV Programs getting crazy when running Unity apps. 1 Answer
getting udp package info inside unity (GlovePIE) 0 Answers
Collision Causing Lag? 1 Answer