Rotating Menu - InvalidCastException Using iTween

Hi,

So, I finally figured out the structure and syntax, but I’ve run into a little snag…

I’ve got the code working, and it’s doing what I want 30% of the time. However, this menu is bugged out. Anyone know why?

Code Below:

using UnityEngine;
using System.Collections;

public class RightFlipper : MonoBehaviour {
	public GameObject academy1;
	public GameObject bluecoats2;
	public GameObject bluedevils3;
	public GameObject blueknights4;
	public GameObject bluestars5;
	public GameObject bostoncrusaders6;
	public GameObject cadets7;
	public GameObject carolinacrown8;
	public GameObject cascades9;
	public GameObject cavaliers10;
	public GameObject colts11;
	public GameObject crossmen12;
	public GameObject glassmen13;
	public GameObject jerseysurf14;
	public GameObject madisonscouts15;
	public GameObject mandarins16;
	public GameObject oregoncrusaders17;
	public GameObject pacificcrest18;
	public GameObject phantomregiment19;
	public GameObject pioneer20;
	public GameObject santaclaravanguard21;
	public GameObject spiritofatlanta22;
	public GameObject troopers23;
	public GameObject southwind24;
	public GameObject skyryders25;
	public GameObject freelancers26;
	public GameObject kingsmen27;
	public GameObject bridgemen28;
	public GameObject velvetknights29;
	public GameObject starofindiana30;
	public GameObject lancers31;
	public GameObject magic32;
	public AudioSource flipAudio;
	public int clickVar;
	
	//Add clickVar here! Example Below...
	void Start() {
			int clickVar = 0;
	}
	
	void OnMouseUp() {
		flipAudio.Play (0);
		clickVar++;
			if (clickVar==32) {
				clickVar=0;
			}
		
			if (clickVar==0) {
			//Academy GUI Box for Corps information on right side of screen.
			}
		
		#region "1 Click"
			if (clickVar==1) {
				//Bluecoats GUI Box for corps information on right side of screen.
				iTween.MoveTo(academy1, iTween.Hash ("x", -3.125, "y", 1.5, "z", 3.125, "time", 1));
				iTween.MoveTo(bluecoats2, iTween.Hash ("x", 0, "y", 1.5, "z", 0, "time", 1));
				iTween.MoveTo(bluedevils3, iTween.Hash ("x", 3.125, "y", 1.5, "z", 3.125, "time", 1));
					iTween.MoveTo(blueknights4, iTween.Hash ("x", 6.25, "y", "1.5", "z", 6.25, "time", 1));
					iTween.MoveTo(bluestars5, iTween.Hash ("x", 9.375, "y", "1.5", "z", 9.375, "time", 1));
					iTween.MoveTo(bostoncrusaders6, iTween.Hash ("x", 12.5, "y", "1.5", "z", 12.5, "time", 1));
				iTween.MoveTo(cadets7, iTween.Hash ("x", 15.625, "y", "1.5", "z", 15.625, "time", 1));
				iTween.MoveTo(carolinacrown8, iTween.Hash ("x", 18.75, "y", "1.5", "z", 18.75, "time", 1));
				iTween.MoveTo(cascades9, iTween.Hash ("x", 21.875, "y", "1.5", "z", 21.875, "time", 1));
					iTween.MoveTo(cavaliers10, iTween.Hash ("x", 25, "y", "1.5", "z", 25, "time", 1));
					iTween.MoveTo(colts11, iTween.Hash ("x", 21.875, "y", "1.5", "z", -28.125, "time", 1));
					iTween.MoveTo(crossmen12, iTween.Hash ("x", 18.75, "y", "1.5", "z", -31.25, "time", 1));
				iTween.MoveTo(glassmen13, iTween.Hash ("x", 15.625, "y", "1.5", "z", -34.375, "time", 1));
				iTween.MoveTo(jerseysurf14, iTween.Hash ("x", 12.5, "y", "1.5", "z", -37.5, "time", 1));
				iTween.MoveTo(madisonscouts15, iTween.Hash ("x", 9.375, "y", "1.5", "z", -40.625, "time", 1));
					iTween.MoveTo(mandarins16, iTween.Hash ("x", 6.25, "y", "1.5", "z", -43.75, "time", 1));
					iTween.MoveTo(oregoncrusaders17, iTween.Hash ("x", 3.125, "y", "1.5", "z", -46.875, "time", 1));
					iTween.MoveTo(pacificcrest18, iTween.Hash ("x", 0, "y", "1.5", "z", -50, "time", 1));
				iTween.MoveTo(phantomregiment19, iTween.Hash ("x", -3.125, "y", "1.5", "z", 46.875, "time", 1));
				iTween.MoveTo(pioneer20, iTween.Hash ("x", -6.25, "y", "1.5", "z", 43.75, "time", 1));
				iTween.MoveTo(santaclaravanguard21, iTween.Hash ("x", -9.375, "y", "1.5", "z", 40.625, "time", 1));
					iTween.MoveTo(spiritofatlanta22, iTween.Hash ("x", -12.5, "y", "1.5", "z", 37.5, "time", 1));
					iTween.MoveTo(troopers23, iTween.Hash ("x", -15.625, "y", "1.5", "z", 34.375, "time", 1));
					iTween.MoveTo(southwind24, iTween.Hash ("x", -18.75, "y", "1.5", "z", 31.25, "time", 1));
				iTween.MoveTo(skyryders25, iTween.Hash ("x", -21.875, "y", "1.5", "z", 28.125, "time", 1));
				iTween.MoveTo(freelancers26, iTween.Hash ("x", -25, "y", "1.5", "z", 25, "time", 1));
				iTween.MoveTo(kingsmen27, iTween.Hash ("x", -21.875, "y", "1.5", "z", 21.875, "time", 1));
					iTween.MoveTo(bridgemen28, iTween.Hash ("x", -18.75, "y", "1.5", "z", 18.75, "time", 1));
					iTween.MoveTo(velvetknights29, iTween.Hash ("x", -15.625, "y", "1.5", "z", 15.625, "time", 1));
					iTween.MoveTo(starofindiana30, iTween.Hash ("x", -12.5, "y", "1.5", "z", 12.5, "time", 1));
				iTween.MoveTo(lancers31, iTween.Hash ("x", -9.375, "y", "1.5", "z", 9.375, "time", 1));
				iTween.MoveTo(magic32, iTween.Hash ("x", -6.25, "y", "1.5", "z", 6.25, "time", 1));
				}
		#endregion "1 Click"
		
		#region "2 Clicks"
			if (clickVar==2) {
				//Blue Devils GUI Box for corps information on right side of screen.
				iTween.MoveTo(academy1, iTween.Hash ("x", -6.25, "y", 1.5, "z", 6.25, "time", 1));
				iTween.MoveTo(bluecoats2, iTween.Hash ("x", -3.125, "y", 1.5, "z", 3.125, "time", 1));
				iTween.MoveTo(bluedevils3, iTween.Hash ("x", 0, "y", 1.5, "z", 0, "time", 1));
					iTween.MoveTo(blueknights4, iTween.Hash ("x", 3.125, "y", 1.5, "z", 3.125, "time", 1));
					iTween.MoveTo(bluestars5, iTween.Hash ("x", 6.25, "y", "1.5", "z", 6.25, "time", 1));
					iTween.MoveTo(bostoncrusaders6, iTween.Hash ("x", 9.375, "y", "1.5", "z", 9.375, "time", 1));
				iTween.MoveTo(cadets7, iTween.Hash ("x", 12.5, "y", "1.5", "z", 12.5, "time", 1));
				iTween.MoveTo(carolinacrown8, iTween.Hash ("x", 15.625, "y", "1.5", "z", 15.625, "time", 1));
				iTween.MoveTo(cascades9, iTween.Hash ("x", 18.75, "y", "1.5", "z", 18.75, "time", 1));
					iTween.MoveTo(cavaliers10, iTween.Hash ("x", 21.875, "y", "1.5", "z", 21.875, "time", 1));
					iTween.MoveTo(colts11, iTween.Hash ("x", 25, "y", "1.5", "z", 25, "time", 1));
					iTween.MoveTo(crossmen12, iTween.Hash ("x", 21.875, "y", "1.5", "z", -28.125, "time", 1));
				iTween.MoveTo(glassmen13, iTween.Hash ("x", 18.75, "y", "1.5", "z", -31.25, "time", 1));
				iTween.MoveTo(jerseysurf14, iTween.Hash ("x", 15.625, "y", "1.5", "z", -34.375, "time", 1));
				iTween.MoveTo(madisonscouts15, iTween.Hash ("x", 12.5, "y", "1.5", "z", -37.5, "time", 1));
					iTween.MoveTo(mandarins16, iTween.Hash ("x", 9.375, "y", "1.5", "z", -40.625, "time", 1));
					iTween.MoveTo(oregoncrusaders17, iTween.Hash ("x", 6.25, "y", "1.5", "z", -43.75, "time", 1));
					iTween.MoveTo(pacificcrest18, iTween.Hash ("x", 3.125, "y", "1.5", "z", -46.875, "time", 1));
				iTween.MoveTo(phantomregiment19, iTween.Hash ("x", 0, "y", "1.5", "z", -50, "time", 1));
				iTween.MoveTo(pioneer20, iTween.Hash ("x", -3.125, "y", "1.5", "z", 46.875, "time", 1));
				iTween.MoveTo(santaclaravanguard21, iTween.Hash ("x", -6.25, "y", "1.5", "z", 43.75, "time", 1));
					iTween.MoveTo(spiritofatlanta22, iTween.Hash ("x", -9.375, "y", "1.5", "z", 40.625, "time", 1));
					iTween.MoveTo(troopers23, iTween.Hash ("x", -12.5, "y", "1.5", "z", 37.5, "time", 1));
					iTween.MoveTo(southwind24, iTween.Hash ("x", -15.625, "y", "1.5", "z", 34.375, "time", 1));
				iTween.MoveTo(skyryders25, iTween.Hash ("x", -18.75, "y", "1.5", "z", 31.25, "time", 1));
				iTween.MoveTo(freelancers26, iTween.Hash ("x", -21.875, "y", "1.5", "z", 28.125, "time", 1));
				iTween.MoveTo(kingsmen27, iTween.Hash ("x", -25, "y", "1.5", "z", 25, "time", 1));
					iTween.MoveTo(bridgemen28, iTween.Hash ("x", -21.875, "y", "1.5", "z", 21.875, "time", 1));
					iTween.MoveTo(velvetknights29, iTween.Hash ("x", -18.75, "y", "1.5", "z", 18.75, "time", 1));
					iTween.MoveTo(starofindiana30, iTween.Hash ("x", -15.625, "y", "1.5", "z", 15.625, "time", 1));
				iTween.MoveTo(lancers31, iTween.Hash ("x", -12.5, "y", "1.5", "z", 12.5, "time", 1));
				iTween.MoveTo(magic32, iTween.Hash ("x", -9.375, "y", "1.5", "z", 9.375, "time", 1));
				}
		#endregion "2 Clicks"
		
		#region "3 Clicks"
			if (clickVar==3){
				//Blue Knights GUI Box for corps information on right side of screen.
				iTween.MoveTo(academy1, iTween.Hash ("x", -9.375, "y", 1.5, "z", 9.375, "time", 1));
				iTween.MoveTo(bluecoats2, iTween.Hash ("x", -6.25, "y", 1.5, "z", 6.25, "time", 1));
				iTween.MoveTo(bluedevils3, iTween.Hash ("x", -3.125, "y", 1.5, "z", 3.125, "time", 1));
					iTween.MoveTo(blueknights4, iTween.Hash ("x", 0, "y", 1.5, "z", 0, "time", 1));
					iTween.MoveTo(bluestars5, iTween.Hash ("x", 3.125, "y", 1.5, "z", 3.125, "time", 1));
					iTween.MoveTo(bostoncrusaders6, iTween.Hash ("x", 6.25, "y", "1.5", "z", 6.25, "time", 1));
				iTween.MoveTo(cadets7, iTween.Hash ("x", 9.375, "y", "1.5", "z", 9.375, "time", 1));
				iTween.MoveTo(carolinacrown8, iTween.Hash ("x", 12.5, "y", "1.5", "z", 12.5, "time", 1));
				iTween.MoveTo(cascades9, iTween.Hash ("x", 15.625, "y", "1.5", "z", 15.625, "time", 1));
					iTween.MoveTo(cavaliers10, iTween.Hash ("x", 18.75, "y", "1.5", "z", 18.75, "time", 1));
					iTween.MoveTo(colts11, iTween.Hash ("x", 21.875, "y", "1.5", "z", 21.875, "time", 1));
					//Break 12-31
				iTween.MoveTo(magic32, iTween.Hash ("x", -12.5, "y", "1.5", "z", 12.5, "time", 1));
				}
		#endregion "3 Clicks"
		
			if (clickVar==4){
				//Add coordinates....
			}
			if (clickVar==5){}
			if (clickVar==6){}
			if (clickVar==7){}
			if (clickVar==8){}
			if (clickVar==9){}
			if (clickVar==10){}
		}
}

Picture:


As you can see above, the rotation only takes with it a few particular objects, and not all of them as I told it to.

Suggestions, ideas?

EM

Still trying to fix this. I’m all ears for suggestions.