- Home /
Unity 2D game - objects jerking (only android)
Hi all,
I have a very annoying problem associated with jerking objects - but only on android device. I have simple script, that change position of object (simple texture sprite). On PC it is working well, but on android, in irregular time interval, the object is jerking. I tried a lot of issues, like: FixedUpdate(), LateUpdate(), deltaTime, change Fixed TimeStep, but no one helped me. I try also Vector3.Lerp() but it still don`t work. The script looks like:
void FixedUpdate () {
//transform.position += new Vector3(1, 0, 0) * 2.5f * Time.deltaTime;
target = transform.position + new Vector3(5f * 2.5f * Time.deltaTime, 0, 0);
transform.position = Vector3.Lerp(transform.position, target, 1);
}
Have you any suggestions to resolve that issue? I will be grateful for every help. Sory for my poor English ;)
How much other stuff do you have going on in the scene? $$anonymous$$aybe it's too much for the device? Also, the target is moving... is that what you want to do? I'm guessing lerp could be struggling because the target is being updated every frame. And why 5 * 2.5? Why not just the whole number?
Answer by POLYGAMe · Feb 13, 2014 at 09:28 PM
Basically in that code, all you're doing is moving the sprite continuously on the x axis as the target is offset from the sprite's own position and is constantly moving. If that's the behaviour you want, just use transform.Translate(speed, 0, 0).
Thanks for the reply. I don`t think that this is performance problem. I placed a lot of objects (also try one object, as in this example) on the scene and the problem still occurs. Numbers like 5f * 2.5f, was random numbers, only for test. I move the sprite only on the x axis, because I tested whether complicated operations, or not - in that case, have influence on this issue.