So, I woke up today and though “Ok, I will test some of my old apps to see if they still work right…”
I have mixed feelings about how that went. On the one hand, it was a pain tracking down the bug I immediately found… (four hours of pain to find and fix)… on the other hand, it validates the process.
I ran the spacebugs game I’d worked on some months ago. Seemed to run ok but movement was really jittery. (Also, for some reason the space bug walking around wasn’t animating but I left that aside because the jitter was sickening.) Except… that non-animating bug was super diagnostically significant.
I first went down the trail to make sure the camera was synching on the same frame as the mob that it was tracking. It was.
Finally, I started thinking about that bug. In spacebugs, animation is based on the ‘animation state’ of the character and how far they’ve moved in any direction. So, if the object has moved forward X units in some span of time, the MobAnimationState calculates how much forward velocity that was and uses it to set the “walk” animation and speed. (If the bug had a “walk sideways” animation already then it would mix the two based on side-to-side velocity, etc…) This is nice because it frees up a lot of networking synching issues and makes the mobs very reactive… if you bump the bug, he won’t just slide but walk a little backwards.
Well, he wasn’t animating for the same reason there was jitter. Objects were only updating position every few frames.
I will spare you the rest of a long story on how I found this but it’s related to a change I recently made in SiO2’s SimTime. I got tired of giant time values and so I set it up to initialize the starting simulation time to 0. Thus if your game has been running for 5 seconds, SimTime.getTimeInSeconds() will show 5 seconds. Nice.
However, this poked at a bug in SimEthereal where the remote time source was being synched directly off of System.nanoTime() instead of the real simulation time. So the object visuals were trying to interpolate position at time 1837460837647375 seconds between start and end times of 5 and 5.033 seconds.
3 hours to find the issue, an hour to clean up and fix it. Now SimEthereal lets you specify a custom TimeSource on the server. And I even added a nice log.warn() in there for anyone else who may have this setup issue.
So, hurray for the process… boo for the time sync.