Demigiant Forum

Unity Assets => DOTween & DOTween Pro => Topic started by: jeff.madriaga on November 20, 2015, 03:16:40 PM

Title: DoShake on Camera position has drift
Post by: jeff.madriaga on November 20, 2015, 03:16:40 PM

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?

Title: Re: DoShake on Camera position has drift
Post by: Daniele on November 20, 2015, 11:30:03 PM

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.