For some reason, this error keeps popping up
InvalidCastException: Cannot cast from source type to destination type.
(wrapper dynamic-method) UnityEngine.GameObject.GameObject$GetComponent$ (object,object)
Boo.Lang.Runtime.RuntimeServices.Invoke (object,string,object)
UnityScript.Lang.UnityRuntimeServices.Invoke (object,string,object,System.Type)
ButtonClick…ctor () (at Assets/scripts/ButtonClick.js:1)
and i think i’ve got everything right, because it’s working the way i want it to
i’ve got this script on one object
var Puzzpillar01 : PillarSpin = GameObject.GetComponent(PillarSpin.js);
function OnMouseDown(){
animation.Play("ButtonPress");
Puzzpillar01.spin();
}
and this one on another
var position : String = "0";
function spin () {
if (position == "0") {
position = "1";
animation.Play("Puzzpillarspin0");
}
else if (position == "1") {
position = "2";
animation.Play("Puzzpillarspin1");
}
else if (position == "2") {
position = "3";
animation.Play("Puzzpillarspin2");
}
else if (position == "3") {
position = "4";
animation.Play("Puzzpillarspin3");
}
else if (position == "4") {
position = "5";
animation.Play("Puzzpillarspin4");
}
else if (position == "5") {
position = "0";
animation.Play("Puzzpillarspin5");
}
}
and everything seems fine, but the error still keeps popping up. is there a problem with my code?