- Home /
Cant add to array..only subtract
Hey everybody, so in this array I put the x and y positions of my dot objects for a matchmaking game. I tried to check if the columns left and right have the same tag as the dot. leftDot1 works fine but the right one cant be found, even if I just try to print its name. Same with the y axis, down, wich is -1 works nicely, however up (+1) is a null reference, again. Has anyone an idea why rightDot1 is not to be found?
void FindMatches()
{
GameObject leftDot1 = board.allDots[column - 1, row];
GameObject rightDot1 = board.allDots[column + 1, row];
if (leftDot1.tag == this.gameObject.tag && rightDot1.tag == this.gameObject.tag)
{
leftDot1.GetComponent<Dot>().isMatched = true;
rightDot1.GetComponent<Dot>().isMatched = true;
}
}
Answer by kaosermail · Dec 12, 2018 at 02:48 PM
Hi my friend. Maybe you are trying to access a point that is out of the matrix. Try printing the point and see if it is on the left top corner
Your answer
![](https://koobas.hobune.stream/wayback/20220612183832im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Array not updating in inspector 0 Answers
MergeSort function acting strange 0 Answers
Efficient Electrical Grid in Tiled Game 0 Answers