A variable in your code is null
, meaning you will get an Object reference not set an instance of an Object
error, because it is basically nothing. See this StackOverflow question for more info.
Double check that all your variables are assigned to.
Assuming you are talking about this line:
position = new Vector2(monitoPosition.X + monitoTexture.Width / 2 - poopTexture.Width / 2, monitoPosition.Y + monitoTexture.Height / 2);
Make sure that monitoPosition
and poopTexture
are set. You can set a breakpoint on this line to pause the code, and hover over the variables to see if they are null
.