NullReferenceException - why?

I`m having an odd NullReferenceException, when the checkers transforms to another prefab that contains King in its name, here’s the full error,code,etc… http://pastie.org/771312

My guess is that board[oldX, oldY] is null.

Incredibly useful information, if not also incredibly obvious.

My first guess is that when the piece is kinged, some piece of code in there is making it think its old position is a cell outside of the edges of the checkerboard. If that’s the case, that means that your 2D array bounds are larger than your board; otherwise you ought to be getting an IndexOutOfBoundsException here, I think. Does making a red piece a king work?

It could also be a glitch in your king-making code where its board position is nulled and not re-assigned. Something like that.

I couldn’t find the code where a piece is made a king so I couldn’t tell what the actual problem might be.