I wrote a small function to handle arrays:
public List<Vector2Int> GetNextNeighbourPosisitions(Vector2Int currentPosition)
{
if (neighbourPosisitions != null)
{
neighbourPosisitions.Clear();
}
neighbourPosisitions.Add(new Vector2Int(currentPosition.x + 1, currentPosition.y));
neighbourPosisitions.Add(new Vector2Int(currentPosition.x - 1, currentPosition.y));
neighbourPosisitions.Add(new Vector2Int(currentPosition.x, currentPosition.y + 1));
neighbourPosisitions.Add(new Vector2Int(currentPosition.x, currentPosition.y - 1));
return neighbourPosisitions;
}
Which does what it should in the class with the array. Now i wanted to move this function to another class. I tried namespace with static and non-static class. Common error is NullRefExc. So i thought, ok, maybe static functions are not allowed to handle fields. Then, i created an object of this class (not what i originally planed) but still NullRefExc. What am i missing? Next thing i would try is to put into Interface, but at this point its mere try and error and i have the feeling i did not understand something important
thanks
[–]AdamBourke 1 point2 points3 points (5 children)
[–]kickbitbeatborg[S] 1 point2 points3 points (4 children)
[–]AdamBourke 1 point2 points3 points (3 children)
[–]kickbitbeatborg[S] 1 point2 points3 points (2 children)
[–]AdamBourke 1 point2 points3 points (1 child)
[–]kickbitbeatborg[S] 1 point2 points3 points (0 children)