- Home /
Juddering/ choppy camera movement over sprites
Hi,
Firstly, I’m a beginner so apologies if I’m using the wrong terminology…
I’m having a problem with what seems like a fairly common scenario – moving an orthogonal camera over a series of sprites over time.
The issue manifests itself as a juddering or choppiness – as the camera pans, the images seem to leave artefacts momentarily and then corrects itself, and the framerate appears to drop – although it doesn’t report it.
The scene, in its current form, is comprised of the same image repeated horizontally three times, the camera pans over from left to right over a given duration.
Originally, I’ve been using the Fungus framework from the asset store to move the camera, into various ‘Views’. The camera moves and resizes as it travels, which is where I’ve noticed issue.
In order to isolate the issue, I’ve created a scene without any frameworks that uses vanilla Unity code to achieve the same – and the issue remains. As a friend put it, it’s the ‘Hello World’ of 2D game development.
The problem exists in:
The Unity Editor - Windows
Deployed iOS 8 and 9 – on an iPhone 5, 6, 6S and iPad 3
Deployed Android 5 – Nexus 9
When running as a compiled binary on a Windows machine, there’s no juddering.
The isolated version of the scene moves between two points using Vertex3.Lerp for the position, and Mathf.Lerp for the size of the camera, all in an Update method.
Things I’ve tried:
FixedUpdate – I know it’s for physics calculations, but I was willing to try anything.
Using Time.time
Using Time.fixedTime
Profiling
The results seem to point to WaitForTargetFPS, which seems to take 60% of the processing time. However, following some research the recommendation is to disable V-Sync, which I’ve tried – and it’s made no difference.
Reducing the size of the image from their original 2048px down to 1024px.
Reducing the image quality in Photoshop.
Using a different image.
Creating one larger image instead of three next to each other.
Only moving the camera, not resizing it too.
Lerping the value in a Coroutine and using the value to move the camera in the Update method.
It’s worth noting that the FPS seems to remain around 90 to 100fps in the editor, on my machine at least. This behaviour has existed on Unity v5, v5.1 and v5.2.
I’ve included a sample project that shows the problem, here’s the link - http://1drv.ms/1PwDhUi
Any help would be greatly appreciated!
I left an answer here from a similar issue. Perhaps the fix can work for you.
Essentially you need to calculate the fixed-update delta time passed between two events and use that figure ins$$anonymous$$d of relying on DeltaTime/fixedDeltaTime.
http://answers.unity3d.com/questions/1012337/player-or-background-stutter.html
Your answer
Follow this Question
Related Questions
how i can write a text from another code ? 2 Answers
Staring a 2D game 2 Answers
(2D) Camera negative boundaries 0 Answers
Help With Next Level Script 2 Answers
Mouse Position returns wired values with Cinemachine2D 1 Answer