Hi every one, in a lot of games i made, not only with unity, I always have the same problem:
When i have an object moving quite fast (like an object in a runner game), or rotating, now and then the game has a little “snap”…i don’t know if that’s the right english word, sorry, so i’ll explain better:
it is like the game lose a frame, like it freeze for a fraction of second and then in the next frame it recovers both of them with this horrible non-fluid effect.
The sad part is that the games i’m talking about are stable on 60 fps, the one i’m making right now, for now it’s only a rotating circle, and still the problem is there
i rotate directly the circle in the update method, how it is different from late update??
edit:
ok, i searched for the method…that’s very usefull, i didn’t know it, but it does not solv my problem, because i’m not rotating the camera, but the object on the screen
Ok right so since the camera isn’t moving at all then late update shouldn’t be an issue here. The snap as your described is a pretty common issue with updating the camera’s position via Update rather than LateUpdate. Is it possible that you are creating a lot of objects and dereferencing them pretty fast? This could cause the garbage collector to create a stuttering affect when it is cleaning up, I had a similar issue before.
although just a quick edit to avoid confusion, I’m not suggesting that you change update to lateupdate on the gameobject because you are rotating it, that’s fine, I’m talking about if the camera moves at all it should be done so with a lateupdate. Assuming you do have a script to move the Camera and it’s not stationary as I’m imagining, it should be done so in the late update otherwise it will cause issues as the one you described to occur. Of course I’m not ruling out that this is the only way this issue occurs.
if this snap appears in profiler as a spike, this means there is a script or something causing this…
if it doesn’t appear in profiler, there is something in movements causes snap… if you use for your movement both physics and translate, i suggest using one of them not both.
It might help to know how you’ve coded your camera. When I first started working in Unity I wrote a camera script that made a function call every frame to a function that squarerooted multiple quantities and called itself recursively a couple of times. Needless to say this caused a 900% increase in computation time.