#no, this name ==== Figure.GetFigure(

1 messages · Page 1 of 1 (latest)

velvet trail
#

So the value in vector

ChessVector vector = ChessVector.GetCoordinatesFromVector(transform.position);

should ba a vector representation of the coordinates of the piece you clicked on

figure.getfigure returns the piece stored in your chessboard array, at the location of your piece. Are you sure your king doesn't have a (0,0) chessvector resulting in a negative index or something?

#

well you would have an error if that were the case

velvet trail
#

yeah

#

what is your check for isvalid, other than preventing a negative index

pulsar verge
#
    public bool isValid()
    {
        return this.x >= 1 && this.x <= 8 &&
                this.y >= 1 && this.y <= 8;
    }```
velvet trail
#

oh wow, you have really neat and simple code

pulsar verge
#

i just clicked all the figures nearby king

velvet trail
#

so everything is working but the king

pulsar verge
#

yes

velvet trail
#

how do you load pieces into the chessboard array?

#

are you sure your king is getting loaded into the array?

pulsar verge
#
    public static void SetFigure(Figure figure)
    {
        chessBoard[figure.coords.x - 1, figure.coords.y - 1] = figure;
    }```
velvet trail
#

can you try running
Debug.Log($" {Figure.GetFigure(vector).figure.name}"); in your start method, so we can tell if it's the getfigure statement failing to find the king?

#

maybe you could say started or something to tell it apart

pulsar verge
#

Debug.Log($" {Figure.GetFigure(new ChessVector(5, 1)).figure.name}");

velvet trail
#

so the creation works, it can find itself, but clicking on it doesn't work, even though it does work for your other objects

#

and they all use the same script for that too

pulsar verge
velvet trail
#

what is .obj?

#

where is that from

pulsar verge
velvet trail
#

alright I'm gonna sleep on this, because I'm not sure and it's 5:30 for me so I'm not an effective thinker rn. ill ping you tomorrow if I have an idea