- Home /
Laggy camera on const moving speed
Hello,
I'm building a 2D game with a camera moving at a const speed over a bunch of sprites (2048x1024). The camera moves pretty laggy though, and the result is that the sprites seem to be "jumping" when the camera scrolls over them. The lagginess occurs both on PC and Android device.
I must be doing something wrong because this scenario is too basic...
I use this to update the camera position:
void Update () {
transform.position = new Vector3 (transform.position.x + 5 * Time.deltaTime, 0, -10);
}
I'm also attaching a screenshot of my camera settings, for what it worth.
Anyone can help me with this?
Thanks! Noam
How many sprites do you have? I assume the 1024 x 2048 is the size of the texture used on the sprites? What does the Stats say (click on 'Stats' in the upper right of the game window)?
For simplicity I reduced it for just 1 sprite. Its resolution is 4096x1024 but in Unity its defined with max size of 2048 (because not all Android devices can render 4096). Sorry if I'm using bad terms - but I guess yes - this it is the texture size used on my sprite.
I'm attaching info from my PC stats and other relevant info, not sure how to see the stats on my Android device - but the behavior is worse there.
Does the issue still occur with just one texture? According to the Stat data, you are running at 60+ fps.
Bumping thread...
I just need an answer to a simple question: how to make a camera move smoothly over a sprite? Are there special requirements from the sprite/camera that needs to be met in order to have smooth movement?
I mean - its as simple as opening an image on Windows and scrolling left and right - why is unity having such trouble doing so?
Thanks, Noam
You should try the same test with smaller image resolutions and varieties in shader properties attached to your objects. For example, a very large image with a large amount of transparency might not perform well on extremely weak video processing hardware. This form of "video lag" would appear to result in stuttering movement.
Answer by Madeck · Sep 29, 2014 at 08:16 AM
What happens if instead you use the following function to update the camera position:
transform.position = new Vector3 (5 * Time.time, 0, -10);
Although it is probably a minimal change, I feel like using deltaTime for your camera position can induce errors in the long run.
Tried - no difference. The problem starts right on the beginning, so long run is not a factor here.
I'm trying to understand whether this is a coding problem or a weak device problem...for example when running the same code in Windows Phone I don't see such laggyness... But on the other hand I have only 1 sprite...is that so difficult to render?
Your answer
Follow this Question
Related Questions
Slow camera move speed? 2 Answers
Camera rotation on mouse drag? 2 Answers
even just cubes moving seems choppy 1 Answer
Mac Team Server Updates are slow 2 Answers