# Unity - strange performance impact with moving objects

I'm trying to find the solution for 46 hours now and I'd be really happy if someone knows it!

I'm using a DOTween library for moving the objects. I also use LeanTween, cause I heard it's faster but none of these work for me in this case. I've used tweening libraries alot, but never faced an issue like this.

The bug appeared in my project, so to check it I created a blank one. An empty scene, with a camera and one cube with scale[10,2,10].

Now, I've added a simple script:

    Sequence sequence = DOTween.Sequence();

sequence.Insert(0f, transform.DOMove(transform.position + new Vector3(10f,0f,0f),1f)).SetEase(Ease.Linear);
sequence.Insert(1f, transform.DOMove(homePosition,1f)).SetEase(Ease.Linear);
sequence.SetDelay(1f);
sequence.SetLoops(-1);


The script moves the cube continously by 10 units to the right, and back (both in 1 second).

There's a noticable jitter.

This jitter is strange, cause it does not happen contantly. It choses a time and just freezes the cube in place for a really tiny amount of time which is noticable - when you see a smoothly moving object and it freezes for a moment.

As you can see, there's a linear interpolation, but I've tried with many (it's even better visible with other interplation types).

Now. The profiler is not the case, cause I've tested it on the empty project with one object on the scene.

• Turning off occlusion culling
• Turning off everything I could
• All the combinations of quality settings

The one thing I came up with is the profiler's WaitForTargetFramerate. By definition, when WFTF is huge it means that the app is doing well, cause it finished it's work and waits for the next frame. In my opinion in this case it's the reason of the bug.

I have a screenshot of the profiler window (with one cube, one directional light and this script attached to a cube):

Now, I'm not 100% sure, but I think that this jitter may happen on these V-Sync drops on the screen.

Everything is tested on the PC. On Android there's the same thing (a noticable jitter), but I didn't run the profiler.

If someone has any idea what may be the cause of this - I'd be grateful. I'll put a bounty here as soon as I can, cause I'm really tired! :)

@ DMGregory

This is before the 'jump' on the GPU chart:

and that's on the 'jump':

There's no RigidBody or Collider, but on my main project there are box colliders on these floors. I've also tried adding RB with the Interpolation checked. No difference.

@ Josh Hamilton

Even if this is a normal behavior, that the frame completed faster - there are games on Google Play and AppleStore without any glitches like this. In my main project (where I discovered the issue) the biggest problem is that this lag is happening when I move the camera to follow the player smoothly and the freeze it noticable like anywhere else. Like the entire enviroment was freezing for 1-3 frames.

• Do you get any details about what's in that purple "other" category on the GPU? Is that the WaitForTargetFramerate or something else? Also, does your object have any physics components like a collider or rigidbody? – DMGregory May 3 '17 at 22:26
• Turn off Vsync and try setting a target framerate (change it a few times try values like 30, 45, 60), see if that changes anything. Those dips shouldn't be anything bad because it just means that frame was done faster than the others. – John Hamilton May 4 '17 at 4:57
• I've edited my question, added answers to your questions. Thank you both for your attention :) – Jacob May 4 '17 at 6:51
• I've also read yesterday that this may be caused by physics & non-physics systems collision. On my main project some objects are being moved with physics (the player) and the camera and floors are moving with tweens (velocity, transforms) – Jacob May 4 '17 at 6:53
• Where is your script located? Start? – McAden May 4 '17 at 23:35