I'm getting a strange glitch in my game when I start it, sometimes I'll get a null reference exception, while other times my characters will seem to rubberband for a second before settling down.It can also trigger the enemy AI which is only supposed to happen when the bounding spheres intersect, so I am assuming that when they move erratically for that second, it happens.
Hm... do you happen to spawn any of your NPCs close or on top of each other? Also, are you making sure to spawn your NPCs slightly above the ground instead of right at ground level?
Most physics issues seem to occur when there's an immediate collision upon their creation.
That helps, though spawning above ground takes a lot of tweaking to avoid the character floating down to the ground.
I've definitely spawned all characters above ground, but this glitch still appears intermittently.Also, my AI triggers, and all the enemies advance, which they should only do when the player bounding sphere intersects the enemy bounding sphere.
Hi steve,
If you set a breakpoint in the ai OnCollision method you should be able to see why the player is interacting with the ai object (eg: their positions / bounds might overlap during that frame).
Are you still seeing the null exception? If so please post the stack trace from when the application halts in Visual Studio, it will help identify the problem.
Let me know if this helps!
Follow me on Twitter – development and personal tweetsAwesome XNA Videos – Lighting, Rendering, and game videos
I haven't seen the null exception in a while, but if it re-occurs, I'll post the stack trace.The player is a good distance away from the enemy, my theory is that as the level starts, the bounding spheres are momentarily out of place, before being transformed to their correct location, maybe they are all at (0,0,0) for a second?
dirtysteve: The player is a good distance away from the enemy, my theory is that as the level starts, the bounding spheres are momentarily out of place, before being transformed to their correct location, maybe they are all at (0,0,0) for a second?
The player is a good distance away from the enemy, my theory is that as the level starts, the bounding spheres are momentarily out of place, before being transformed to their correct location, maybe they are all at (0,0,0) for a second?
That could be the case if you're submitting your player and enemies to the object manager, and then re-positioning them. So I'd double check that you're setting their positions before you submit them.