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.
Things I've already tried:
- Turning off occlusion culling
- Turning off everything I could
- All the combinations of quality settings
- LeanTween instead of DoTween
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:
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.
No comments:
Post a Comment