I have NGUI events driving a camera target based on the OnDrag() mouse delta.
Separately, I have the camera following this target doing some fancy stuff (like tilting) based on a derived delta in LateUpdate().
Unfortunately, my camera movement was very jittery, so I started logging the frame and deltas reported just inside the mouse's OnDrag() method and the camera's LateUpdate() method. Here's what that looks like:
Frame: 88 Mouse: (-8.2, -7.4)
Frame: 88 Camera: (0.1, 0.0, 0.1)
Frame: 89 Mouse: (-2.2, -4.4)
Frame: 89 Camera: (0.0, 0.0, 0.1)
Frame: 90 Mouse: (-1.5, -5.9)
Frame: 90 Camera: (0.0, 0.0, 0.1)
Frame: 91 Mouse: (0.7, -18.5)
Frame: 91 Camera: (0.0, 0.0, 0.4)
Frame: 92 Camera: (0.0, 0.0, 0.0)
Frame: 93 Mouse: (5.9, -11.1)
Frame: 93 Camera: (-0.1, 0.0, 0.2)
Frame: 94 Camera: (0.0, 0.0, 0.0)
Frame: 95 Mouse: (26.0, -25.2)
Frame: 95 Camera: (-0.5, 0.0, 0.5)
Frame: 96 Camera: (0.0, 0.0, 0.0)
Frame: 97 Mouse: (19.3, -11.9)
Frame: 97 Camera: (-0.3, 0.0, 0.2)
Frame: 98 Mouse: (22.3, -12.6)
Frame: 98 Camera: (-0.4, 0.0, 0.2)
Frame: 99 Mouse: (11.9, -4.5)
Frame: 99 Camera: (-0.2, 0.0, 0.1)
I've highlighted what looks like the problem. While the camera's LateUpdate() is being called consistently every frame, you can see that OnDrag() is not. As the camera delta is derived from the OnDrag() mouse delta, when OnDrag() misses a frame, the camera's delta becomes 0, introducing a single frame jitter on things that rely on this delta (such as tilting).
What I'd like to know is if I'm missing something or making a silly mistake that could easily fix this, or if I need to explore a more involved solution, such as keeping a history of deltas for smoothing. If it's the latter, I'd love any better suggestions.
Thanks!