public void SwitchState() { GameObject.FindGameObjectWithTag("Player").GetComponent <WeaponScript>().AddAmmo(); if (currentState == gameplayState) { gameplayState.ExitState(); pauseState.EnterState(); currentState = pauseState; } else if (currentState == pauseState) { pauseState.ExitState(); gameplayState.EnterState(); currentState = gameplayState; } }