Timer Problem

Hi everyone Im running into an Error. Im trying to make a timer to spawn an Enemy, once you hit a trigger. The timer counts down, but I run into this error

Control cannot fall through from one case label ‘case “EnemyTrigger”’ to another.

Here is the code:

using UnityEngine;
using System.Collections;

public class SpawnManager : MonoBehaviour {

	public GameObject Enemy;
	public float mytimer = 5.0f;
void OnTriggerEnter(Collider other)
			case "EnemyTrigger":

				if(mytimer > 0){
					mytimer -=Time.deltaTime;


					Transform enemy;
					GameObject enemySpawnPoint = GameObject.Find("EnemySpawn");
					enemy =    Instantiate(Enemy,enemySpawnPoint.transform.position,enemySpawnPoint.transform.rotation) as Transform; 
					Debug.Log("Spawned Enemy");

Can anybody explain to me what the error is saying? And also what should I do to change it?

A switch condition is required to have a break. You’ve placed your ‘break’ inside the ‘else’ clause which means that if mytimer is greater than 0, you don’t hit a break. Solutions:

  • Move the ‘break’ outside of the else clase

  • Untested, but you probably can add a break inside the ‘if’ clause

  • Given this current code, delete the switch and just do:

    if (other.gameObject.name == “EnemyTrigger”)