heres my code snippet:
#pragma strict
function SelectPiece(){
// select piece to play
var pieceScore : int[]; // piece move value/score
pieceScore = new int[4]; // new array
var pValue : int; // move value
var last : int; // last piece value
var piece : int; // piece to play (piece is declared as an int - does unity cast this to object by default? )
switch(game.turn){ // select playing player
case PlayerTurn.P1:
if(gameScript.players[1] == Player.cpu){ // if CPU player
for(var x = 0;x < 4;x++){ // loop pieces
pieceScore[x] = GetPieceScore(gameScript.p1pieces[x]); // get piece score
}
for(x = 0;x < 4;x++){ // loop pieces scores
pValue = pieceScore[x]; // get piece value
if(pValue > last){ // if this piece has greater value then last piece
last = pValue; // set new last best score
piece = x; // set playing piece
}
}
isSelect = true; // set piece selected
gameScript.p1pieces[piece].GetComponent("piece1").Click(PlayerTurn.P1); // i get the error here// CPU play/click on selected piece
}
break;
i dont see anyway of casting this to a gameObject without getting the error “unity cannot convert int to UnityEngine.GameObject”
Please help!!! I know there are other post relating to this issue, but none of them directly addresses this issue. Im open to doing hella more research so if there are any links id be happy to explore them. I actually want to learn why this happens also or is it just IOS not supporting dynamic typing?
Thanks Guys!