- Home /
Switch Statement question
What's wrong with this (assume all variables are correct (they exist)).
switch (sideType) { case (1) : Instantiate (building1, position + Vector3(20 + roadWidth,0,0), transform.rotation); Instantiate (building1, position - Vector3(20 -roadWidth, 0, 0), transform.rotation);
break;
case (2) :
Instantiate (building2, position + Vector3(20 + roadWidth,0,0), transform.rotation);
Instantiate (building2, position - Vector3(20 -roadWidth, 0, 0), transform.rotation);
break;
case (3) :
Instantiate (building3, position + Vector3(20 + roadWidth,0,0), transform.rotation);
Instantiate (building2, position - Vector3(20 -roadWidth, 0, 0), transform.rotation);
break;
case (4) :
Instantiate (fountain, position + Vector3(20 + roadWidth,0,0), transform.rotation);
Instantiate (fountain, position - Vector3(20 -roadWidth, 0, 0), transform.rotation);
break;
case (5) :
Instantiate (park, position + Vector3(20 + roadWidth,5,0), transform.rotation);
Instantiate (park, position - Vector3(20 -roadWidth, 5, 0), transform.rotation);
break;
A bracket is missing at the end. Is that the problem?
I have never really seen paranthesis "()" being used for a single numeric digit for the case label..remove that.
No, that's just part of a larger code. The strange problem is that it never instantiates a 'park'.
Your answer
Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer
switch always defaults 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Switch Statements 1 Answer