Hi Everybody!
i am new here in unity and i’m working in a chess-like board game. What I want to do is change the color of the board piece when a player piece pass above it.
So, here is what i’ve done so far:
while(new Vector2(i, j) != _coordFinal)
{
_piecePath.Add(new Vector2(i,j));
if(_boardPieces[i,j] != 0)
{
CollisionBool = true;
break;
}
i += _incX;
j += _incY;
}
while checking the path of the player piece, I also add each of the coordinates in the _piecePath List.
Then in the board Tile class:
void Update () {
positions = new Vector2(this.gameObject.transform.position.x,this.gameObject.transform.position.z);
if (_GM._piecePath.Contains(positions)) {
GetComponent<Renderer> ().material.SetColor ("_Color",pathColor);
}
}
then I recieved null exception and nothing happens in the board.