Anyway, I get the errors very seldom and they don't seem to have much negative effect at least that I've ever noticed. Nonetheless, I would like to get rid of them. I've used the ErrorLog to track down where in my code I am receiving them from and it seems to be a fairly odd place.
First of all, it's happening inside of the GotMessage function for one of my calls "enemyHit", which fires when an enemy is attacked. The only objects I mention on the lines that the error is occuring on is the player object that is passed into the function and "enemy_array[i]" which is the enemy that was hit. Nowhere inside that call is the player or "enemy_array[i]" ever set to null, so I'm not sure why I am getting that error. Unless I could be reading something wrong and it's a dumb mistake, but so far that doesn't seem to be the issue. =P
Inside my main gameloop is the only time an enemy object from the enemy_array should ever be set to null.
So one of my possible ideas, is that.. Is it possible for the player to disconnect; be set to null; then the GotMessage function fire and throw an error because player is null? Or is it also possible for the GotMessage function to fire and at the SAME TIME, the gameloop be executing as well? The problem is strange to me because this is how the error seems to be appearing. (Simple example)
- Code: Select all
//Simple example
player.x += enemy_array[i].x;
player.x += enemy_array[i].x;
player.x += enemy_array[i].x; //error happens here for example
player.x += enemy_array[i].x;
So I don't know why I would be getting errors in the middle of that code instead of on the first line. Maybe it's some stupid mistake and I'm overlooking something, but I'm not sure. I'm not nearly as experienced in C# as I am AS3, so maybe it's some type of multi-threading thing where multiple lines of code are running at the same time? Or maybe that's not the problem. Some help or insight would be much appreciated though. Thanks!