DoShake on Camera position has drift
« on: November 20, 2015, 03:16:40 PM »
Hi,

I experienced something during a smoke test, where i left a tween running.

I'm trying to applying a camera shake with DOShakePosition on the camera transform. During the application, this happens frequently and sometimes on consecutive frames in a row (The tween has a duration of 0.5 secs, randomness - 90). Over time, the camera would drift off its initial position.

I ran some more tests where i call DOShakePosition every frame for 200 frames, in this sense i expect the tween to be overridden with the new starting position and drift. I added an OnComplete setting the position to the cached inital transform position. At the very least the last call should set it back to default position. After the 200th call the camera had drifted, even though its positioned looked correct.

Is it good practice to force cancel the existing tween, before setting a new one? I was under the impression DoTween handled that by default? Have you ever experienced drift in position?

Thanks

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: DoShake on Camera position has drift
« Reply #1 on: November 20, 2015, 11:30:03 PM »
Hi,

DOTween doesn't have an override manager, because of its architecture (and because it would require Reflection, which I really want to avoid). So yes, multiple tweens will fight each other and especially on a Shake tween drift will happen, because the starting position will vary each time. I strongly recommend killing (actually, better completing it in this case) the previous tween manually before starting a new one on the same properties.

Cheers,
Daniele