Fluxuations in framerate and non-uniform translation and UVscrolling

We are attempting to build simple multiplatform 2d games but have noticed that the animation within unity is not as smooth as we would like. When compiled to either a stand alone executable or webplayer we have noticed pauses and skips in object translation and UV scrolling. We have tested this on a number of windows and mac machines and so far only one of the machines has consistantly performed well.

As a test I have built a simple project in an attempt to reduce the number of variables in the problem. The project only consists of a plane with a texture that is animated by UV scrolling. This example is at it’s core just one line of code in update:

 material.mainTextureOffset += velocity * Time.deltaTime;

where material is cached version of this.renderer.material and velocity is a public variable. I have included a link to the project if you would like to take a look.

http://dl.dropbox.com/u/22825039/SimpleUV.zip

I have poked around and have noticed that the deltaTime between frames varies wildly. I wrote a script to investigate this (not included) and found that I was getting the occasional blip that was nearly 3 or 4 times the average. The windows machine usually maintained a deltaTime between 0.045s and 0.005. On the mac the results were more interesting and puzzling as the deltaTime fluctuated constantly between 0.016s and 0.017s with only an occasional spike.

just a few more notes:

  • fullscreen appears to run slightly better
  • webplayer is by far the worse
  • Vsync has little or no affect
  • TargetFramerate has little or no affect
  • remove the plane and UV scrolling and the deltaTime still fluxuates
  • profiler has the occsional spike in other

so, ultimately my question is this: what is going on? Is unity3d this unstable?

At least the UV scrolling problem can be explained: setting the offset to huge values gives unexpected results. You can solve this by “moduloing” the offset between 0 and 1 (see similar question on mainTextureOffset setTextureOffset with big value offset - Questions & Answers - Unity Discussions). The fps rate usually fluctuates somewhat, because frames are just rendered one after other, without any attempt to keep some pre-defined fps. In a game I’m currently developing, the frame rate depends mainly on how many objects are in the camera’s view angle (or frustum, to be more precise), even when they are obscured by mountains, buildings etc. You can have an idea of what is being drawn clicking the Stats button in the Game view. My game runs at 16 fps most of time, but when my Windows notebook decides to do some God-knows-what internal task, the fps rate falls to 5 until this damned task ends. Another big CPU cycle thief is the physics engine: if you have a lot of active rigidbodies in your game, they may consume a high slice of your CPU time. Since it’s done in a different pace, you may have a “beating” effect which will make FPS fluctuate at a slower rate.