I got a null pointer exception when referencing position. In the debug view i found 2 different variables with the same name. One seems to be null and has a green circle, one is the correct variable and has a blue triangle next to it.
Why is my code referencing the null variable and why would there be 2 copies of that variable in memory?
The position gets set in the constructor here
public Obstacle(int x, int y) {
position = new PVector(x,y);
}
The constructor gets called from a level generator class here
obstacle1 = new Obstacle(levelWidth/4, 375);
obstacle2 = new Obstacle(levelWidth/2, 375);
obstacle3 = new Obstacle(levelWidth*3/4, 375);
Not sure what other code to show.