I recently had another soul-crushing bug on my hands that I did not know how to fix, so I scrambled for a workaround. Instead of getting depressed for 2 months andÂ ignoring Marble Maze for the duration, it only took me 2 days to shake it off and find a way to make it work. But if I couldn’t make it workÂ this would have been a deal breaker, for sure. Probably would have made me go to 2D development where everything is under my control, and makes sense. 🙂
Basically I had a concept of the physics engine representation of the Whirlygig models, and it took about a dozen iterations of trial and error before I found something that works. Here were some of the major stages of the race…
- A convex hull collision with an upvector joint, and using impulse forces to push the model around. This had serious performance issues (too many contact points, I believe?) and I could only have about 20 models running at any given time on my fast PC. Bounce collision with the player was not consistent, either.Â No good.
- A sphere collision with an upvector joint, and using Impulse to push the model around. This had less performance issues than the previous attempt but the model would jump around a bit and cause problems. I also received random issues where all of a sudden a physics object would have position/velocity of 1.#QNAN (yes you read that right). It caused the object to disappear from the world. It also happened to the player marble which is the most bizarre thing of all, and the player would be treated to a black screen stuck inside never-never-land. This 1.#QNAN is some sort of floating number corruption that is caused by divide by zero or negative exponents, or something. Google it, it freaks me out just thinking of what inside the wrapper or Newton DLL that could cause this.
- A sphere collision with no upvector joint (thinking that may cause the corruption) and using Impulse. The 1.#QNAN issue still happened. ByÂ then IÂ was getting very frustrated.
- A sphere collision with no upvector joint, and using actual Forces instead of Impulse. This made the collisions skip all about and behave kind of weird. Still got the 1.#QNAN problem too.
- A sphere collision, no upvector joint, and use Omega forces (just like the player) to move the sphere around. Bingo. We have a winner.
So what caused the 1.#QNAN ? I still have no clue, and I hope I don’t ever see it again. It is obviously some memory corruption of some kind (wrapper or Newton, I wouldn’t know) and it was extremely random.Â Â A problem with using Impulse/Forces on too many objects?Â Sometimes it would happen to the player marble as soon as a the Whirlygigs began to move. Sometimes it would happen part way through. Sometimes I could run the level of 25 Whirlygigs bopping around for 5 minutes before some of them started disappearing, one by one. It is maddening!
And thusÂ my struggle with programming a complex system which utilizes 3rd party software that I can’t really get into or debug.
HavingÂ models represented by spheres in the physics engine will work for a majority of the enemies planned, but will not work for some of the more interesting ones, such as the flip-truck and the slimey oozes.Â I’m not sure how those will be handled or if I’m stuck with a rolling sphere for everything.
But it seems to work now, no major bugs.Â It doesn’t work perfectly: I eventually want these Whirlygigs to slow down and stop on a dime.Â And sometimes the Whirlygig thinks it shouldn’t move when it should.Â But it works.